|
1 | | - |
2 | | -def I_TEST_CONFIGURATIONS = [ |
3 | | - [ os: 'linux' , ws: 'gtk' , arch: 'x86_64' , javaVersion: 21], |
4 | | - [ os: 'linux' , ws: 'gtk' , arch: 'x86_64' , javaVersion: 25], |
5 | | - [ os: 'macosx', ws: 'cocoa', arch: 'aarch64', javaVersion: 21], |
6 | | - [ os: 'macosx', ws: 'cocoa', arch: 'x86_64' , javaVersion: 21], |
7 | | - [ os: 'win32' , ws: 'win32', arch: 'x86_64' , javaVersion: 21], |
8 | | -] |
9 | | -def Y_TEST_CONFIGURATIONS = [ |
10 | | - [ os: 'linux' , ws: 'gtk' , arch: 'x86_64' , javaVersion: 21], |
11 | | - [ os: 'linux' , ws: 'gtk' , arch: 'x86_64' , javaVersion: 25], |
12 | | - [ os: 'macosx', ws: 'cocoa', arch: 'aarch64', javaVersion: 21], |
13 | | - [ os: 'macosx', ws: 'cocoa', arch: 'x86_64' , javaVersion: 21], |
14 | | -] |
15 | | -def BUILD = { |
16 | | - def matcher = "$JOB_BASE_NAME" =~ '(?<type>[IY])-build-(?<major>\\d).(?<minor>\\d+)' |
17 | | - if (matcher) { |
18 | | - def buildConfig = [ type: matcher.group('type'), testPrefix: "ep${matcher.group('major')}${matcher.group('minor')}${matcher.group('type')}-unit"] |
19 | | - switch(buildConfig.type) { |
20 | | - case 'I': return [*:buildConfig, |
21 | | - typeName: 'Integration' , branchLabel: 'master', |
22 | | - mailingList: ' [email protected]', testJobFolder:'AutomatedTests', testConfigurations: I_TEST_CONFIGURATIONS] |
23 | | - case 'Y': return [*:buildConfig, |
24 | | - typeName: 'Beta Java 25', branchLabel: 'java25', |
25 | | - mailingList: ' [email protected]' , testJobFolder:'YBuilds' , testConfigurations: Y_TEST_CONFIGURATIONS] |
26 | | - } |
27 | | - } |
28 | | - error("Unsupported job: $JOB_BASE_NAME" ) |
29 | | -}() |
30 | | - |
31 | | -def testConfigurationsExpected = BUILD.testConfigurations.collect{c -> |
32 | | - "${BUILD.testPrefix}-${c.os}-${c.arch}-java${c.javaVersion}_${c.os}.${c.ws}.${c.arch}_${c.javaVersion}" |
33 | | - }.join(',') |
| 1 | +@groovy.transform.Field |
| 2 | +def BUILD = null |
34 | 3 |
|
35 | 4 | pipeline { |
36 | 5 | options { |
@@ -63,43 +32,42 @@ spec: |
63 | 32 | ant 'apache-ant-latest' |
64 | 33 | } |
65 | 34 | environment { |
66 | | - BUILD_TYPE = "${BUILD.type}" |
67 | | - BUILD_TYPE_NAME = "${BUILD.typeName}" |
68 | | - PATCH_OR_BRANCH_LABEL = "${BUILD.branchLabel}" |
69 | | - |
70 | 35 | MAVEN_OPTS = '-Xmx4G' |
71 | 36 | CJE_ROOT = "${WORKSPACE}/cje-production" |
72 | 37 | logDir = "$CJE_ROOT/buildlogs" |
73 | | - TEST_CONFIGURATIONS_EXPECTED = "${testConfigurationsExpected}" |
74 | 38 | } |
75 | 39 | stages { |
76 | | - stage('Setup intial configuration'){ |
| 40 | + stage('Set up environment') { |
77 | 41 | steps { |
78 | | - dir("${CJE_ROOT}") { |
79 | | - sh ''' |
80 | | - chmod +x mbscripts/* |
81 | | - mkdir -p $logDir |
82 | | - ''' |
| 42 | + script { // Extend build configuration with data from the configuration file |
| 43 | + def matcher = "$JOB_BASE_NAME" =~ '(?<type>[IY])-build-(?<major>\\d).(?<minor>\\d+)' |
| 44 | + if (!matcher) { |
| 45 | + error("Unsupported job: $JOB_BASE_NAME") |
| 46 | + } |
| 47 | + assignEnvVariable('BUILD_TYPE', matcher.group('type')) |
| 48 | + def configurations = readJSON(file: "${WORKSPACE}/JenkinsJobs/buildConfigurations.json") |
| 49 | + BUILD = configurations["${BUILD_TYPE}"] |
| 50 | + assignEnvVariable('BUILD_TYPE_NAME', BUILD.typeName) |
| 51 | + assignEnvVariable('PATCH_OR_BRANCH_LABEL', BUILD.branchLabel) |
| 52 | + assignEnvVariable('TEST_NAME_PREFIX', "ep${matcher.group('major')}${matcher.group('minor')}${BUILD_TYPE}-unit") |
| 53 | + assignEnvVariable('TEST_CONFIGURATIONS_EXPECTED', BUILD.tests.collect{ c -> |
| 54 | + "${TEST_NAME_PREFIX}-${c.os}-${c.arch}-java${c.javaVersion}_${c.os}.${c.ws}.${c.arch}_${c.javaVersion}" |
| 55 | + }.join(',')) |
83 | 56 | } |
84 | | - } |
85 | | - } |
86 | | - stage('Generate environment variables'){ |
87 | | - steps { |
88 | | - dir("${CJE_ROOT}/mbscripts") { |
89 | | - sh ''' |
90 | | - set -eo pipefail |
91 | | - ./mb010_createEnvfiles.sh $CJE_ROOT/buildproperties.shsource 2>&1 | tee $logDir/mb010_createEnvfiles.sh.log |
92 | | - ''' |
| 57 | + dir("${CJE_ROOT}") { |
| 58 | + sh ''' |
| 59 | + set -eo pipefail |
| 60 | + chmod +x mbscripts/* |
| 61 | + mkdir -p $logDir |
| 62 | + |
| 63 | + ./mbscripts/mb010_createEnvfiles.sh ${CJE_ROOT}/buildproperties.shsource 2>&1 | tee $logDir/mb010_createEnvfiles.sh.log |
| 64 | + ''' |
93 | 65 | } |
94 | | - } |
95 | | - } |
96 | | - stage('Export environment variables stage 1'){ |
97 | | - steps { |
98 | 66 | script { |
99 | 67 | def buildProps = readBuildProperties("${CJE_ROOT}/buildproperties.properties") |
100 | | - env.BUILD_IID = buildProps.BUILD_TYPE + buildProps.TIMESTAMP |
101 | | - env.STREAM = buildProps.STREAM |
102 | | - env.RELEASE_VER = buildProps.RELEASE_VER |
| 68 | + assignEnvVariable('BUILD_IID', buildProps.BUILD_TYPE + buildProps.TIMESTAMP) |
| 69 | + assignEnvVariable('STREAM', buildProps.STREAM) |
| 70 | + assignEnvVariable('RELEASE_VER', buildProps.RELEASE_VER) |
103 | 71 | } |
104 | 72 | } |
105 | 73 | } |
@@ -294,11 +262,11 @@ spec: |
294 | 262 | } |
295 | 263 | } |
296 | 264 | } |
297 | | - stage('Trigger tests'){ |
| 265 | + stage('Trigger tests') { |
298 | 266 | steps { |
299 | 267 | script { |
300 | | - for (c in BUILD.testConfigurations) { |
301 | | - build job: "${BUILD.testJobFolder}/${BUILD.testPrefix}-${c.os}-${c.arch}-java${c.javaVersion}", wait: false, parameters: [ |
| 268 | + for (c in BUILD.tests) { |
| 269 | + build job: "${BUILD.testJobFolder}/${TEST_NAME_PREFIX}-${c.os}-${c.arch}-java${c.javaVersion}", wait: false, parameters: [ |
302 | 270 | string(name: 'buildId', value: "${BUILD_IID}") |
303 | 271 | ] |
304 | 272 | } |
@@ -359,6 +327,12 @@ spec: |
359 | 327 | } |
360 | 328 | } |
361 | 329 |
|
| 330 | +@NonCPS |
| 331 | +def assignEnvVariable(String name, String value) { |
| 332 | + env[name] = value |
| 333 | + println("${name}=${value}") |
| 334 | +} |
| 335 | + |
362 | 336 | def readBuildProperties(String buildPropertiesFile){ |
363 | 337 | return readProperties(file: buildPropertiesFile, charset: 'UTF-8').collectEntries{n, v -> |
364 | 338 | v = v.trim(); |
|
0 commit comments