forked from NotHarshhaa/DevOps-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
66 lines (66 loc) · 2.06 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
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/vishal2505/terraform-eks-cicd.git']])
}
}
}
stage('Initializing Terraform'){
steps {
script {
dir('tf-aws-eks'){
sh 'terraform init'
}
}
}
}
stage('Validating Terraform'){
steps {
script {
dir('tf-aws-eks'){
sh 'terraform validate'
}
}
}
}
stage('Terraform Plan'){
steps {
script {
dir('tf-aws-eks'){
sh 'terraform plan -var-file=variables/dev.tfvars'
}
input(message: "Are you sure to proceed?", ok: "Proceed")
}
}
}
stage('Creating/Destroying EKS Cluster'){
steps {
script {
dir('tf-aws-eks'){
sh 'terraform $action -var-file=variables/dev.tfvars -auto-approve'
}
}
}
}
stage('Deploying Nginx Application') {
steps{
script{
dir('manifest') {
sh 'aws eks update-kubeconfig --name my-eks-cluster'
sh 'kubectl create namespace eks-nginx-app'
sh 'kubectl apply -f deployment.yaml -n eks-nginx-app'
sh 'kubectl apply -f service.yaml -n eks-nginx-app'
}
}
}
}
}
}