forked from cyberark/secretless-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
259 lines (220 loc) · 6.48 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/usr/bin/env groovy
pipeline {
agent { label 'executor-v2' }
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr: '30'))
}
triggers {
cron(getDailyCronString())
}
stages {
stage('Validate') {
parallel {
stage('Changelog') {
steps { sh './bin/parse-changelog' }
}
}
}
stage('Update Submodules') {
steps {
sh 'git submodule update --init --recursive'
}
}
stage('Build Images') {
steps {
sh './bin/build'
}
}
stage('Scan Secretless') {
parallel {
stage('Scan Secretless Image for fixable issues') {
steps {
scanAndReport("secretless-broker:latest", "HIGH", false)
}
}
stage('Scan Secretless Image for all issues') {
steps {
scanAndReport("secretless-broker:latest", "NONE", true)
}
}
stage('Scan Secretless Quickstart for fixable issues') {
steps {
scanAndReport("secretless-broker-quickstart:latest", "HIGH", false)
}
}
stage('Scan Secretless Quickstart for all issues') {
steps {
scanAndReport("secretless-broker-quickstart:latest", "NONE", true)
}
}
stage('Scan Secretless RedHat for fixable issues') {
steps {
script {
TAG = sh(returnStdout: true, script: '. bin/build_utils && full_version_tag')
}
scanAndReport("secretless-broker-redhat:${TAG}", "HIGH", false)
}
}
stage('Scan Secretless RedHat for all issues') {
steps {
script {
TAG = sh(returnStdout: true, script: '. bin/build_utils && full_version_tag')
}
scanAndReport("secretless-broker-redhat:${TAG}", "NONE", true)
}
}
stage('Scan For Security with Gosec') {
// Gosec only works on branch builds
when {
not { tag "v*" }
}
steps {
sh "./bin/check_golang_security -s High -c Medium -b ${env.BRANCH_NAME}"
junit(allowEmptyResults: true, testResults: 'gosec.output')
}
}
}
}
stage('Integration Tests') {
steps {
script {
def directories = sh (
returnStdout: true,
// We run the 'find' directive first on all directories with test files, then run a 'find' directive
// to make sure they also contain start files. We then take the dirname, and basename respectively.
script:
'''
find $(find ./test -name test) -name 'start' -exec dirname {} \\; | xargs -n1 basename
'''
).trim().split()
def integrationSteps = [:]
// Create an integration test stage for each directory we collected previously.
// We want to be sure to skip any tests, such as keychain tests, that can only be ran manually.
directories.each { name ->
if (name == "keychain") return
def stepName = "Integration: ${name}"
integrationSteps[stepName] = {
sh "./bin/run_integration ${name}"
junit "**/test/**/junit.xml"
}
}
parallel integrationSteps
}
}
}
stage('Run Tests') {
parallel {
stage('Unit tests') {
steps {
sh './bin/test_unit'
junit 'test/unit-test-output/junit.xml'
cobertura autoUpdateHealth: true, autoUpdateStability: true, coberturaReportFile: 'coverage.xml', conditionalCoverageTargets: '30, 0, 0', failUnhealthy: true, failUnstable: false, lineCoverageTargets: '30, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '30, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
ccCoverage("gocov", "--prefix github.com/cyberark/secretless-broker")
}
}
stage('Quick start') {
steps {
sh './bin/test_demo'
}
}
stage('K8s Demo') {
steps {
sh 'summon -f ./k8s-ci/secrets.yml ./k8s-ci/test demos/k8s-demo'
}
}
stage('CRD test') {
steps {
sh 'summon -f ./k8s-ci/secrets.yml ./k8s-ci/test k8s-ci/k8s_crds'
}
}
}
}
stage('Push Images Internally') {
when {
branch 'master'
}
steps {
sh './bin/publish_internal'
}
}
stage('Build Release Artifacts') {
when {
branch 'master'
}
steps {
sh './bin/build_release --snapshot'
archiveArtifacts 'dist/goreleaser/'
}
}
stage('Release') {
// Only run this stage when triggered by a tag
when { tag "v*" }
parallel {
stage('Push Images') {
steps {
// The tag trigger sets TAG_NAME as an environment variable
sh 'summon -e production ./bin/publish'
}
}
stage('Create draft release') {
steps {
dir('./pristine-checkout') {
// Go releaser requires a pristine checkout
checkout scm
sh 'git submodule update --init --recursive'
// Create draft release
sh "summon --yaml 'GITHUB_TOKEN: !var github/users/conjur-jenkins/api-token' ./bin/build_release"
archiveArtifacts 'dist/goreleaser/'
}
}
}
}
}
stage('Fix Website Flags (staging)') {
when {
branch 'staging'
}
steps {
sh 'sed -i "s#^is_maintenance_mode:.*#is_maintenance_mode: false#" docs/_config.yml'
}
}
stage('Build Website') {
steps {
sh './bin/build_website'
}
}
stage('Check Links') {
steps {
sh './bin/check_website_links'
}
}
stage('Publish') {
parallel {
stage('Publish Website (staging)') {
when {
branch 'staging'
}
steps {
sh 'summon -e staging bin/publish_website'
archiveArtifacts 'docs/_site/'
}
}
stage('Publish Website (production)') {
when {
branch 'master'
}
steps {
sh 'summon -e production bin/publish_website'
archiveArtifacts 'docs/_site/'
}
}
}
}
}
post {
always {
cleanupAndNotify(currentBuild.currentResult)
}
}
}