-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile-eks
55 lines (47 loc) · 1.7 KB
/
Jenkinsfile-eks
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
pipeline {
agent any
environment {
AWS_ACCESS_KEY_ID=credentials('aws_access_key')
AWS_SECRET_ACCESS_KEY=credentials('aws_access_key_value')
}
parameters {
booleanParam( defaultValue: true, description: '',name: 'apply' )
booleanParam( defaultValue: false, description: '',name: 'destroy' )
}
stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/selvanayaki678/terraform-aws.git']]])
}
}
stage ('checking current dir'){
steps {
sh 'pwd;ls;printenv'
}
}
stage ('EKS terraform init & Plan')
{
steps {
sh 'cd EKS/cluster;terraform init;pwd;terraform plan -var-file=eks-cluster-use2.tfvars'
}
}
stage ('EKS Terraform apply')
{
when {
expression { return params.apply == true }
}
steps {
sh 'cd EKS/cluster;terraform apply -var-file=eks-cluster-use2.tfvars --auto-approve'
}
}
stage ('EKS Terraform destroy')
{
when {
expression { return params.destroy == true }
}
steps {
sh 'cd EKS/cluster;terraform destroy -var-file=eks-cluster-use2.tfvars --auto-approve'
}
}
}
}