-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile2
34 lines (34 loc) · 1.14 KB
/
Jenkinsfile2
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
pipeline {
agent any
environment {
AWS_ACCESS_KEY = credentials('accesskey')
AWS_SECRET_KEY = credentials('secretkey')
AWS_KEY = credentials('aws')
DOCKER = credentials('Docker')
}
parameters {
choice(
choices: ['Init' , 'Destroy'],
description: '',
name: 'REQUESTED_ACTION')
}
stages {
stage ('Init') {
when {
expression { params.REQUESTED_ACTION == 'Init' }
}
steps {
sh 'terraform -chdir=init_prod init'
sh 'terraform -chdir=init_prod apply -auto-approve -var="key=$AWS_KEY" -var="accesskey=$AWS_ACCESS_KEY" -var="secretkey=$AWS_SECRET_KEY" -var="DockerLogin=$DOCKER_USR" -var="DockerPsw=$DOCKER_PSW"'
}
}
stage ('Destroy') {
when {
expression { params.REQUESTED_ACTION == 'Destroy' }
}
steps {
sh 'terraform -chdir=init_prod destroy -auto-approve -var="accesskey=$AWS_ACCESS_KEY" -var="secretkey=$AWS_SECRET_KEY" '
}
}
}
}