This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
91 lines (77 loc) · 1.98 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env groovy
pipeline {
agent { label 'executor-v2' }
options {
timestamps()
buildDiscarder(logRotator(daysToKeepStr: '30'))
}
environment {
INSTANCE_ID_FILE = "EC2.txt"
AMI_ID_FILE = "AMI.txt"
}
parameters {
string(name: 'CONJUR_VERSION', defaultValue: 'latest', description: 'Version of Conjur to build into AMI (e.g. 5.x.x)')
}
triggers {
cron(getDailyCronString())
}
stages {
stage('Validate') {
parallel {
stage('Changelog') {
steps { sh './parse-changelog.sh' }
}
}
}
stage('Build the Conjur AMI') {
steps {
sh "summon ./build-ami.sh ${params.CONJUR_VERSION}"
archiveArtifacts "*.txt,vars/*.yml"
milestone(1) // AMI is now built
}
}
stage('Render CFN template for testing') {
steps {
sh "./render-cft.sh ${params.CONJUR_VERSION}"
archiveArtifacts 'conjur*.yml' // CFN stack files
}
}
stage('Test the CFN template') {
steps {
sh "summon ./test.sh"
milestone(2) // AMI has been tested
}
}
stage('Promote AMI to other regions') {
when {
branch 'master'
}
steps {
sh './promote-to-regions.sh $(cat AMI.txt)'
archiveArtifacts 'vars/*'
sh "./render-cft.sh ${params.CONJUR_VERSION}" // re-render here to pick up all AMIs
archiveArtifacts 'conjur*.yml'
}
}
stage('Publish CFT') {
when {
branch 'master'
}
steps {
sh "summon ./publish-cft.sh ${params.CONJUR_VERSION}"
}
}
}
post {
always {
sh 'docker run -i --rm -v $PWD:/src -w /src alpine/git clean -fxd'
deleteDir()
}
failure {
slackSend(color: 'danger', message: "${env.JOB_NAME} #${env.BUILD_NUMBER} FAILURE (<${env.BUILD_URL}|Open>)")
}
unstable {
slackSend(color: 'warning', message: "${env.JOB_NAME} #${env.BUILD_NUMBER} UNSTABLE (<${env.BUILD_URL}|Open>)")
}
}
}