-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
199 lines (179 loc) · 6.15 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env groovy
@Library(['product-pipelines-shared-library', 'conjur-enterprise-sharedlib']) _
// Automated release, promotion and dependencies
properties([
// Include the automated release parameters for the build
release.addParams(),
// Dependencies of the project that should trigger builds
dependencies([])
])
// Performs release promotion. No other stages will be run
if (params.MODE == "PROMOTE") {
release.promote(params.VERSION_TO_PROMOTE) { infrapool, sourceVersion, targetVersion, assetDirectory ->
// Any assets from sourceVersion Github release are available in assetDirectory
// Any version number updates from sourceVersion to targetVersion occur here
// Any publishing of targetVersion artifacts occur here
// Anything added to assetDirectory will be attached to the Github Release
//Note: assetDirectory is on the infrapool agent, not the local Jenkins agent.
}
release.copyEnterpriseRelease(params.VERSION_TO_PROMOTE)
return
}
pipeline {
agent { label 'conjur-enterprise-common-agent' }
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr: '30'))
lock resource: "tas-infra"
}
triggers {
cron(getDailyCronString())
}
environment {
// Sets the MODE to the specified or autocalculated value as appropriate
MODE = release.canonicalizeMode()
}
stages {
// Aborts any builds triggered by another project that wouldn't include any changes
stage ("Skip build if triggering job didn't create a release") {
when {
expression {
MODE == "SKIP"
}
}
steps {
script {
currentBuild.result = 'ABORTED'
error("Aborting build because this build was triggered from upstream, but no release was built")
}
}
}
stage('Get InfraPool ExecutorV2 Agent(s)') {
steps {
script {
// Request ExecutorV2 agents for 1 hour
infrapool = getInfraPoolAgent.connected(type: "ExecutorV2", quantity: 1, duration: 1)[0]
}
}
}
// Generates a VERSION file based on the current build number and latest version in CHANGELOG.md
stage('Validate Changelog and set version') {
steps {
script {
updateVersion(infrapool, "CHANGELOG.md", "${BUILD_NUMBER}")
}
}
}
stage('Get latest upstream dependencies') {
steps {
script {
updatePrivateGoDependencies("${WORKSPACE}/conjur-env/go.mod")
infrapool.agentPut from: "conjur-env/vendor", to: "${WORKSPACE}/conjur-env/"
infrapool.agentPut from: "conjur-env/go.*", to: "${WORKSPACE}/conjur-env/"
infrapool.agentPut from: "/root/go", to: "/var/lib/jenkins/"
}
}
}
stage('Package') {
steps {
script {
infrapool.agentSh './package.sh --skip-gomod-download && ./unpack.sh'
infrapool.agentArchiveArtifacts(artifacts: 'conjur_buildpack*.zip')
}
}
}
stage('Test') {
parallel {
stage('Integration Tests') {
steps {
script {
env.INFRAPOOL_JENKINS_HOME = env.JENKINS_HOME
infrapool.agentSh './ci/test_integration'
sh 'mkdir -p tests/integration/reports/integration'
infrapool.agentGet(
from: 'tests/integration/reports/integration/*.xml',
to: 'tests/integration/reports/integration/'
)
junit 'tests/integration/reports/integration/*.xml'
}
}
}
// Disabled as allocateTas isn't currently available.
// stage('End To End Tests') {
// steps {
// script {
// env.INFRAPOOL_JENKINS_HOME = env.JENKINS_HOME
// allocateTas.withTas(infrapool, 'isv_ci_tas_srt_5_0'){
// infrapool.agentSh 'summon -f ./ci/secrets.yml ./ci/test_e2e'
// sh 'mkdir -p tests/integration/reports/e2e'
// infrapool.agentGet(
// from: 'tests/integration/reports/e2e/*.xml',
// to: 'tests/integration/reports/e2e/'
// )
// junit 'tests/integration/reports/e2e/*.xml'
// }
// }
// }
// }
stage('Unit Tests') {
stages {
stage("Secret Retrieval Script Tests") {
steps {
script {
infrapool.agentSh './tests/retrieve-secrets/start'
infrapool.agentGet(
from: 'TestReport-test.xml',
to: 'TestReport-test.xml'
)
junit 'TestReport-test.xml'
}
}
}
stage("Conjur-Env Unit Tests") {
steps {
script {
infrapool.agentSh './ci/test_conjur-env'
infrapool.agentGet(
from: 'conjur-env/output/*.xml',
to: 'conjur-env/output/'
)
junit 'conjur-env/output/*.xml'
}
}
}
}
}
}
}
stage('Release') {
when {
expression {
MODE == "RELEASE"
}
}
steps {
script {
release(infrapool, { billOfMaterialsDirectory, assetDirectory ->
/* Publish release artifacts to all the appropriate locations
Copy any artifacts to assetDirectory on the infrapool node
to attach them to the Github release.
If your assets are on the infrapool node in the target
directory, use a copy like this:
infrapool.agentSh "cp target/* ${assetDirectory}"
Note That this will fail if there are no assets, add :||
if you want the release to succeed with no assets.
If your assets are in target on the main Jenkins agent, use:
infrapool.agentPut(from: 'target/', to: assetDirectory)
*/
infrapool.agentSh "cp conjur_buildpack*.zip ${assetDirectory}"
})
}
}
}
}
post {
always {
releaseInfraPoolAgent()
}
}
}