-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.matrix_version
93 lines (87 loc) · 2.33 KB
/
Jenkinsfile.matrix_version
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
pipeline {
agent {
docker {
image 'centos:my-centos'
args '-u 0:0 --privileged'
}
}
stages {
stage("Gather Vault Tokens") {
steps {
script {
env.DEV_VAULT_TOKEN = input(message: 'Insert DEV Vault Token', id: 'DEV_VAULT_TOKEN', parameters: [string(name: 'Dev Token')])
env.STAGE_VAULT_TOKEN = input(message: 'Insert STAGE Vault Token', id: 'STAGE_VAULT_TOKEN', parameters: [string(name: 'Stage Token')])
env.PROD_VAULT_TOKEN = input(message: 'Insert PROD Vault Token', id: 'PROD_VAULT_TOKEN', parameters: [string(name: 'Prod Token')])
env.VAULT_SKIP_VERIFY = "true"
}
}
}
stage('Install Dependencies') {
steps {
sh 'make install-dependencies'
}
}
stage("Test And Deploy") {
matrix {
axes {
axis {
name 'ENV'
values 'dev', 'stage', 'prod'
}
}
stages {
stage("Test") {
when {
not {
branch 'master'
}
}
steps {
withEnv(["ENV=${ENV}"]) {
sh "make test/checkov"
}
}
}
stage("Plan") {
when {
// When a Pull-request
allOf {
changeRequest target: 'master'
}
}
steps {
withEnv(["VAULT_TOKEN=${DEV_VAULT_TOKEN}", "ENV=${ENV}"]) {
withAWS(region: 'us-east-1', credentials: 'my-aws-credentials') {
sh "make terraform/init"
sh "make terraform/plan"
}
}
}
}
stage("Apply") {
when {
// When a Pull-request
allOf {
changeRequest target: 'master'
}
}
steps {
withEnv(["VAULT_TOKEN=${DEV_VAULT_TOKEN}", "ENV=${ENV}"]) {
withAWS(region: 'us-east-1', credentials: 'my-aws-credentials') {
sh "make terraform/init"
sh "make terraform/plan"
sh "make terraform/apply"
}
}
}
}
}
}
}
}
post {
always {
sh "rm -rf terraform"
}
}
}