@@ -12,7 +12,7 @@ H 6,21 * * 3''')])
12
12
properties(listOfProperties)
13
13
14
14
// Default environment variable set to allow images publication
15
- def envVars = [" PUBLISH=true" ]
15
+ def envVars = [' PUBLISH=true' ]
16
16
17
17
// Set to true in a replay to simulate a LTS build on ci.jenkins.io
18
18
// It will set the environment variables needed for a LTS
@@ -21,184 +21,182 @@ def SIMULATE_LTS_BUILD = false
21
21
22
22
if (SIMULATE_LTS_BUILD ) {
23
23
envVars = [
24
- " PUBLISH=false" ,
25
- " TAG_NAME=2.462.3" ,
26
- " JENKINS_VERSION=2.462.3" ,
27
- " JENKINS_SHA=3e53b52a816405e3b10ad07f1c48cd0cb5cb3f893207ef7f9de28415806b93c1"
24
+ ' PUBLISH=false' ,
25
+ ' TAG_NAME=2.462.3' ,
26
+ ' JENKINS_VERSION=2.462.3' ,
27
+ ' JENKINS_SHA=3e53b52a816405e3b10ad07f1c48cd0cb5cb3f893207ef7f9de28415806b93c1'
28
28
]
29
29
}
30
30
31
31
stage(' Build' ) {
32
32
def builds = [:]
33
33
34
- withEnv (envVars) {
35
- echo " = bake target: linux"
36
-
37
- def windowsImageTypes = [
38
- ' windowsservercore-ltsc2019' ,
39
- ]
40
- for (anImageType in windowsImageTypes) {
41
- def imageType = anImageType
42
- builds[imageType] = {
43
- nodeWithTimeout(' windows-2019' ) {
44
- stage(' Checkout' ) {
45
- checkout scm
46
- }
47
-
48
- withEnv([" IMAGE_TYPE=${ imageType} " ]) {
49
- if (! infra. isTrusted()) {
50
- /* Outside of the trusted.ci environment, we're building and testing
51
- * the Dockerfile in this repository, but not publishing to docker hub
52
- */
53
- stage(" Build ${ imageType} " ) {
54
- infra. withDockerCredentials {
55
- powershell ' ./make.ps1'
56
- }
57
- }
58
-
59
- stage(" Test ${ imageType} " ) {
60
- infra. withDockerCredentials {
61
- def windowsTestStatus = powershell(script : ' ./make.ps1 test' , returnStatus : true )
62
- junit(allowEmptyResults : true , keepLongStdio : true , testResults : ' target/**/junit-results.xml' )
63
- if (windowsTestStatus > 0 ) {
64
- // If something bad happened let's clean up the docker images
65
- error(' Windows test stage failed.' )
66
- }
67
- }
68
- }
69
-
70
- // disable until we get the parallel changes merged in
71
- // def branchName = "${env.BRANCH_NAME}"
72
- // if (branchName ==~ 'master'){
73
- // stage('Publish Experimental') {
74
- // infra.withDockerCredentials {
75
- // withEnv(['DOCKERHUB_ORGANISATION=jenkins4eval','DOCKERHUB_REPO=jenkins']) {
76
- // powershell './make.ps1 publish'
77
- // }
78
- // }
79
- // }
80
- // }
81
- } else {
82
- // Only publish when a tag triggered the build & the publication is enabled (ie not simulating a LTS)
83
- if (env. TAG_NAME && (env. PUBLISH == " true" )) {
84
- // Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
85
- jenkins_version = env. TAG_NAME . split(' -' )[0 ]
86
- withEnv([" JENKINS_VERSION=${ jenkins_version} " ]) {
87
- stage(' Publish' ) {
88
- infra. withDockerCredentials {
89
- withEnv([' DOCKERHUB_ORGANISATION=jenkins' ,' DOCKERHUB_REPO=jenkins' ]) {
90
- powershell ' ./make.ps1 publish'
91
- }
92
- }
93
- }
94
- }
95
- }
96
- }
97
- }
98
- }
99
- }
100
- }
101
-
102
- if (! infra. isTrusted()) {
103
- def images = [
104
- ' alpine_jdk17' ,
105
- ' alpine_jdk21' ,
106
- ' debian_jdk17' ,
107
- ' debian_jdk21' ,
108
- ' debian_slim_jdk17' ,
109
- ' debian_slim_jdk21' ,
110
- ' rhel_ubi9_jdk17' ,
111
- ' rhel_ubi9_jdk21' ,
112
- ]
113
- for (i in images) {
114
- def imageToBuild = i
115
-
116
- builds[imageToBuild] = {
117
- nodeWithTimeout(' docker' ) {
118
- deleteDir()
119
-
120
- stage(' Checkout' ) {
121
- checkout scm
122
- }
123
-
124
- stage(' Static analysis' ) {
125
- sh ' make hadolint shellcheck'
126
- }
127
-
128
- /* Outside of the trusted.ci environment, we're building and testing
129
- * the Dockerfile in this repository, but not publishing to docker hub
130
- */
131
- stage(" Build linux-${ imageToBuild} " ) {
132
- infra. withDockerCredentials {
133
- sh " make build-${ imageToBuild} "
134
- }
135
- }
136
-
137
- stage(" Test linux-${ imageToBuild} " ) {
138
- sh " make prepare-test"
139
- try {
140
- infra. withDockerCredentials {
141
- sh " make test-${ imageToBuild} "
142
- }
143
- } catch (err) {
144
- error(" ${ err.toString()} " )
145
- } finally {
146
- junit(allowEmptyResults : true , keepLongStdio : true , testResults : ' target/*.xml' )
147
- }
148
- }
149
- }
150
- }
151
- }
152
- builds[' multiarch-build' ] = {
153
- nodeWithTimeout(' docker' ) {
154
- stage(' Checkout' ) {
155
- deleteDir()
156
- checkout scm
157
- }
158
-
159
- // sanity check that proves all images build on declared platforms
160
- stage(' Multi arch build' ) {
161
- infra. withDockerCredentials {
162
- sh '''
163
- docker buildx create --use
164
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
165
- docker buildx bake --file docker-bake.hcl linux
166
- '''
167
- }
168
- }
169
- }
170
- }
171
- } else {
172
- // Only publish when a tag triggered the build
173
- if (env. TAG_NAME ) {
174
- // Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
175
- jenkins_version = env. TAG_NAME . split(' -' )[0 ]
176
- builds[' linux' ] = {
177
- withEnv([" JENKINS_VERSION=${ jenkins_version} " ]) {
178
- nodeWithTimeout(' docker' ) {
179
- stage(' Checkout' ) {
180
- checkout scm
181
- }
182
-
183
- stage(' Publish' ) {
184
- // Publication is enabled by default, disabled when simulating a LTS
185
- if (env. PUBLISH == " true" ) {
186
- infra. withDockerCredentials {
187
- sh '''
188
- docker buildx create --use
189
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
190
- make publish
191
- '''
192
- }
193
- }
194
- }
195
- }
196
- }
197
- }
198
- }
199
- }
200
-
201
- parallel builds
34
+ withEnv(envVars) {
35
+ echo ' = bake target: linux'
36
+
37
+ def windowsImageTypes = [' windowsservercore-ltsc2019' ]
38
+ for (anImageType in windowsImageTypes) {
39
+ def imageType = anImageType
40
+ builds[imageType] = {
41
+ nodeWithTimeout(' windows-2019' ) {
42
+ stage(' Checkout' ) {
43
+ checkout scm
44
+ }
45
+
46
+ withEnv([" IMAGE_TYPE=${ imageType} " ]) {
47
+ if (! infra. isTrusted()) {
48
+ /* Outside of the trusted.ci environment, we're building and testing
49
+ * the Dockerfile in this repository, but not publishing to docker hub
50
+ */
51
+ stage(" Build ${ imageType} " ) {
52
+ infra. withDockerCredentials {
53
+ powershell ' ./make.ps1'
54
+ }
55
+ }
56
+
57
+ stage(" Test ${ imageType} " ) {
58
+ infra. withDockerCredentials {
59
+ def windowsTestStatus = powershell(script : ' ./make.ps1 test' , returnStatus : true )
60
+ junit(allowEmptyResults : true , keepLongStdio : true , testResults : ' target/**/junit-results.xml' )
61
+ if (windowsTestStatus > 0 ) {
62
+ // If something bad happened let's clean up the docker images
63
+ error(' Windows test stage failed.' )
64
+ }
65
+ }
66
+ }
67
+
68
+ // disable until we get the parallel changes merged in
69
+ // def branchName = "${env.BRANCH_NAME}"
70
+ // if (branchName ==~ 'master'){
71
+ // stage('Publish Experimental') {
72
+ // infra.withDockerCredentials {
73
+ // withEnv(['DOCKERHUB_ORGANISATION=jenkins4eval','DOCKERHUB_REPO=jenkins']) {
74
+ // powershell './make.ps1 publish'
75
+ // }
76
+ // }
77
+ // }
78
+ // }
79
+ } else {
80
+ // Only publish when a tag triggered the build & the publication is enabled (ie not simulating a LTS)
81
+ if (env. TAG_NAME && (env. PUBLISH == ' true' )) {
82
+ // Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
83
+ jenkins_version = env. TAG_NAME . split(' -' )[0 ]
84
+ withEnv([" JENKINS_VERSION=${ jenkins_version} " ]) {
85
+ stage(' Publish' ) {
86
+ infra. withDockerCredentials {
87
+ withEnv([' DOCKERHUB_ORGANISATION=jenkins' , ' DOCKERHUB_REPO=jenkins' ]) {
88
+ powershell ' ./make.ps1 publish'
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ if (! infra. isTrusted()) {
101
+ def images = [
102
+ ' alpine_jdk17' ,
103
+ ' alpine_jdk21' ,
104
+ ' debian_jdk17' ,
105
+ ' debian_jdk21' ,
106
+ ' debian_slim_jdk17' ,
107
+ ' debian_slim_jdk21' ,
108
+ ' rhel_ubi9_jdk17' ,
109
+ ' rhel_ubi9_jdk21' ,
110
+ ]
111
+ for (i in images) {
112
+ def imageToBuild = i
113
+
114
+ builds[imageToBuild] = {
115
+ nodeWithTimeout(' docker' ) {
116
+ deleteDir()
117
+
118
+ stage(' Checkout' ) {
119
+ checkout scm
120
+ }
121
+
122
+ stage(' Static analysis' ) {
123
+ sh ' make hadolint shellcheck'
124
+ }
125
+
126
+ /* Outside of the trusted.ci environment, we're building and testing
127
+ * the Dockerfile in this repository, but not publishing to docker hub
128
+ */
129
+ stage(" Build linux-${ imageToBuild} " ) {
130
+ infra. withDockerCredentials {
131
+ sh " make build-${ imageToBuild} "
132
+ }
133
+ }
134
+
135
+ stage(" Test linux-${ imageToBuild} " ) {
136
+ sh ' make prepare-test'
137
+ try {
138
+ infra. withDockerCredentials {
139
+ sh " make test-${ imageToBuild} "
140
+ }
141
+ } catch (err) {
142
+ error(" ${ err.toString()} " )
143
+ } finally {
144
+ junit(allowEmptyResults : true , keepLongStdio : true , testResults : ' target/*.xml' )
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ builds[' multiarch-build' ] = {
151
+ nodeWithTimeout(' docker' ) {
152
+ stage(' Checkout' ) {
153
+ deleteDir()
154
+ checkout scm
155
+ }
156
+
157
+ // sanity check that proves all images build on declared platforms
158
+ stage(' Multi arch build' ) {
159
+ infra. withDockerCredentials {
160
+ sh '''
161
+ docker buildx create --use
162
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
163
+ docker buildx bake --file docker-bake.hcl linux
164
+ '''
165
+ }
166
+ }
167
+ }
168
+ }
169
+ } else {
170
+ // Only publish when a tag triggered the build
171
+ if (env. TAG_NAME ) {
172
+ // Split to ensure any suffix is not taken in account (but allow suffix tags to trigger rebuilds)
173
+ jenkins_version = env. TAG_NAME . split(' -' )[0 ]
174
+ builds[' linux' ] = {
175
+ withEnv([" JENKINS_VERSION=${ jenkins_version} " ]) {
176
+ nodeWithTimeout(' docker' ) {
177
+ stage(' Checkout' ) {
178
+ checkout scm
179
+ }
180
+
181
+ stage(' Publish' ) {
182
+ // Publication is enabled by default, disabled when simulating a LTS
183
+ if (env. PUBLISH == ' true' ) {
184
+ infra. withDockerCredentials {
185
+ sh '''
186
+ docker buildx create --use
187
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
188
+ make publish
189
+ '''
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ parallel builds
202
200
}
203
201
}
204
202
0 commit comments