-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsFile
74 lines (74 loc) · 2.14 KB
/
JenkinsFile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
pipeline {
agent any
environment {
AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
AWS_DEFAULT_REGION = "us-east-1"
}
stages {
stage('Checkout SCM'){
steps{
script{
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/X3N064/EKS-n-Jenkin.git']])
}
}
}
stage('Initializing Terraform'){
steps{
script{
dir('tfs-eks'){
sh 'terraform init'
}
}
}
}
stage('Formatting Terraform Code'){
steps{
script{
dir('tfs-eks'){
sh 'terraform fmt'
}
}
}
}
stage('Validating Terraform'){
steps{
script{
dir('tfs-eks'){
sh 'terraform validate'
}
}
}
}
stage('Previewing the Infra using Terraform'){
steps{
script{
dir('tfs-eks'){
sh 'terraform plan'
}
input(message: "Are you sure to proceed?", ok: "Proceed")
}
}
}
stage('Creating/Destroying an EKS Cluster'){
steps{
script{
dir('tfs-eks') {
sh 'terraform $action --auto-approve'
}
}
}
}
stage('Deploying Nginx Application') {
steps{
script{
dir('tfs-eks/ConfigurationFiles') {
sh 'aws eks update-kubeconfig --name my-eks-cluster'
sh 'kubectl apply -f deployment.yaml'
sh 'kubectl apply -f service.yaml'
}
}
}
}
}
}