From 44a9096265f2929461423bc7717bdd5795b6a2e6 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 10:33:18 +0100 Subject: [PATCH 01/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../build_pipeline_generator.groovy | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index 4ad8634fa..d8b650237 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -166,7 +166,8 @@ node('worker') { releaseType : 'Nightly' ] - def target + // Ensure target is initialized to [], otherwise groovy uses previous iteration state...! + def target = [] try { target = load "${WORKSPACE}/${nightlyFolderPath}/jdk${javaVersion}.groovy" } catch (NoSuchFileException e) { @@ -192,17 +193,16 @@ node('worker') { checkoutUserPipelines() } } + println "[INFO] JDK${javaVersion}: loaded target configuration: ${target}" config.put('targetConfigurations', target.targetConfigurations) - // hack as jenkins groovy does not seem to allow us to check if disableJob exists - try { + // Set disableJob if in target + if (target.hasProperty('target.disableJob')) { config.put('disableJob', target.disableJob) - } catch (Exception ex) { - config.put('disableJob', false) } - if (enablePipelineSchedule.toBoolean()) { + if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_nightly')) { config.put('pipelineSchedule', target.triggerSchedule_nightly) } @@ -231,8 +231,6 @@ node('worker') { checkoutUserPipelines() } - target.disableJob = false - generatedPipelines.add(config['JOB_NAME']) // Create weekly release pipeline @@ -251,7 +249,7 @@ node('worker') { // Load weeklyTemplatePath. This is where the weekly_release_pipeline_job_template.groovy code is located compared to the repository root. This actually sets up the weekly pipeline job using the parameters above. def weeklyTemplatePath = (params.WEEKLY_TEMPLATE_PATH) ?: DEFAULTS_JSON['templateDirectories']['weekly'] - if (enablePipelineSchedule.toBoolean()) { + if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_weekly')) { config.put('pipelineSchedule', target.triggerSchedule_weekly) } config.releaseType = "Weekly" @@ -272,8 +270,6 @@ node('worker') { checkoutUserPipelines() } - target.disableJob = false - generatedPipelines.add(config['JOB_NAME']) }) From c392bdab7850dda0a266fdc6a597eedb586ea066 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 10:57:01 +0100 Subject: [PATCH 02/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../build/regeneration/build_pipeline_generator.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index d8b650237..b0441c459 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -198,11 +198,11 @@ node('worker') { config.put('targetConfigurations', target.targetConfigurations) // Set disableJob if in target - if (target.hasProperty('target.disableJob')) { + if (target.metaClass.hasProperty(target, 'disableJob')) { config.put('disableJob', target.disableJob) } - if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_nightly')) { + if (enablePipelineSchedule.toBoolean() && target.metaClass.hasProperty(target, 'triggerSchedule_nightly')) { config.put('pipelineSchedule', target.triggerSchedule_nightly) } @@ -249,7 +249,7 @@ node('worker') { // Load weeklyTemplatePath. This is where the weekly_release_pipeline_job_template.groovy code is located compared to the repository root. This actually sets up the weekly pipeline job using the parameters above. def weeklyTemplatePath = (params.WEEKLY_TEMPLATE_PATH) ?: DEFAULTS_JSON['templateDirectories']['weekly'] - if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_weekly')) { + if (enablePipelineSchedule.toBoolean() && target.metaClass.hasProperty(target, 'triggerSchedule_weekly')) { config.put('pipelineSchedule', target.triggerSchedule_weekly) } config.releaseType = "Weekly" From b622cb935452bc88128510c31d383eccfd008db8 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:08:02 +0100 Subject: [PATCH 03/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../build_pipeline_generator.groovy | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index b0441c459..dfd6a83e7 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -193,17 +193,24 @@ node('worker') { checkoutUserPipelines() } } - println "[INFO] JDK${javaVersion}: loaded target configuration: ${target}" + println "[INFO] JDK${javaVersion}: loaded target configuration:" + println target.toJson() config.put('targetConfigurations', target.targetConfigurations) - // Set disableJob if in target - if (target.metaClass.hasProperty(target, 'disableJob')) { + // hack as jenkins groovy does not seem to allow us to check if disableJob exists + try { config.put('disableJob', target.disableJob) + } catch (Exception ex) { + config.put('disableJob', false) } - if (enablePipelineSchedule.toBoolean() && target.metaClass.hasProperty(target, 'triggerSchedule_nightly')) { - config.put('pipelineSchedule', target.triggerSchedule_nightly) + if (enablePipelineSchedule.toBoolean()) { + try { + config.put('pipelineSchedule', target.triggerSchedule_nightly) + } catch (Exception ex) { + config.put('pipelineSchedule', '0 0 31 2 0') // 31st Feb, so will never run + } } if (useAdoptShellScripts.toBoolean()) { @@ -249,8 +256,12 @@ node('worker') { // Load weeklyTemplatePath. This is where the weekly_release_pipeline_job_template.groovy code is located compared to the repository root. This actually sets up the weekly pipeline job using the parameters above. def weeklyTemplatePath = (params.WEEKLY_TEMPLATE_PATH) ?: DEFAULTS_JSON['templateDirectories']['weekly'] - if (enablePipelineSchedule.toBoolean() && target.metaClass.hasProperty(target, 'triggerSchedule_weekly')) { - config.put('pipelineSchedule', target.triggerSchedule_weekly) + if (enablePipelineSchedule.toBoolean()) { + try { + config.put('pipelineSchedule', target.triggerSchedule_weekly) + } catch (Exception ex) { + config.put('pipelineSchedule', '0 0 31 2 0') // 31st Feb, so will never run + } } config.releaseType = "Weekly" From e8eef9d3de342cb7b8fd60e21afc5b80c20e79e1 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:14:09 +0100 Subject: [PATCH 04/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- pipelines/build/regeneration/build_pipeline_generator.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index dfd6a83e7..d6fa14db7 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -194,7 +194,7 @@ node('worker') { } } println "[INFO] JDK${javaVersion}: loaded target configuration:" - println target.toJson() + println JsonOutput.prettyPrint(JsonOutput.toJson(target)) config.put('targetConfigurations', target.targetConfigurations) From e7c51c67cdff20ccf9c5774fcf944dd12c359597 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:21:03 +0100 Subject: [PATCH 05/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- pipelines/build/regeneration/build_pipeline_generator.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index d6fa14db7..72468b096 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -167,7 +167,8 @@ node('worker') { ] // Ensure target is initialized to [], otherwise groovy uses previous iteration state...! - def target = [] + def target = [] + target.clear() try { target = load "${WORKSPACE}/${nightlyFolderPath}/jdk${javaVersion}.groovy" } catch (NoSuchFileException e) { From 6861a6daa6efd1bf46e8bafb652009d22e6356ec Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:47:03 +0100 Subject: [PATCH 06/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../build_pipeline_generator.groovy | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index 72468b096..ddb1fb22f 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -166,9 +166,15 @@ node('worker') { releaseType : 'Nightly' ] - // Ensure target is initialized to [], otherwise groovy uses previous iteration state...! - def target = [] - target.clear() + // Clear any pre-existing variable bindings from previous iteration load.. + def variables = ['targetConfigurations', 'triggerSchedule_nightly', 'triggerSchedule_weekly', 'weekly_release_scmReferences', 'disableJob'] + variables.each({ variable -> + if (binding.hasVariable(variable)) { + binding.removeVariable(variable) + } + }) + + def target try { target = load "${WORKSPACE}/${nightlyFolderPath}/jdk${javaVersion}.groovy" } catch (NoSuchFileException e) { @@ -199,11 +205,8 @@ node('worker') { config.put('targetConfigurations', target.targetConfigurations) - // hack as jenkins groovy does not seem to allow us to check if disableJob exists - try { + if (target.hasVariable('disableJob')) { config.put('disableJob', target.disableJob) - } catch (Exception ex) { - config.put('disableJob', false) } if (enablePipelineSchedule.toBoolean()) { From 4636ca4bf21fee440f7d97594fec834ba2fa763e Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:48:20 +0100 Subject: [PATCH 07/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- pipelines/build/regeneration/build_pipeline_generator.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index ddb1fb22f..aa3a4e067 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -205,7 +205,7 @@ node('worker') { config.put('targetConfigurations', target.targetConfigurations) - if (target.hasVariable('disableJob')) { + if (target.hasProperty('disableJob')) { config.put('disableJob', target.disableJob) } From 74c1ee38ee4fac684cdb3ad131d177810a2765e5 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:55:40 +0100 Subject: [PATCH 08/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../regeneration/build_pipeline_generator.groovy | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index aa3a4e067..d788dafb7 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -166,14 +166,6 @@ node('worker') { releaseType : 'Nightly' ] - // Clear any pre-existing variable bindings from previous iteration load.. - def variables = ['targetConfigurations', 'triggerSchedule_nightly', 'triggerSchedule_weekly', 'weekly_release_scmReferences', 'disableJob'] - variables.each({ variable -> - if (binding.hasVariable(variable)) { - binding.removeVariable(variable) - } - }) - def target try { target = load "${WORKSPACE}/${nightlyFolderPath}/jdk${javaVersion}.groovy" @@ -286,6 +278,12 @@ node('worker') { } generatedPipelines.add(config['JOB_NAME']) + + // config.load() loads into the current groovy binding, and returns "this", so we need to reset variables before next load of target + def variables = ['targetConfigurations', 'triggerSchedule_nightly', 'triggerSchedule_weekly', 'weekly_release_scmReferences', 'disableJob'] + variables.each({ variable -> + target[variable] = null + }) }) // Fail if nothing was generated From 09a64689fd43dd5ba1343475d1d6f0fac96c5e2c Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 11:58:46 +0100 Subject: [PATCH 09/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../build/regeneration/build_pipeline_generator.groovy | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index d788dafb7..30e60f4f1 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -280,10 +280,11 @@ node('worker') { generatedPipelines.add(config['JOB_NAME']) // config.load() loads into the current groovy binding, and returns "this", so we need to reset variables before next load of target - def variables = ['targetConfigurations', 'triggerSchedule_nightly', 'triggerSchedule_weekly', 'weekly_release_scmReferences', 'disableJob'] - variables.each({ variable -> - target[variable] = null - }) + target.targetConfigurations = [] + target.triggerSchedule_nightly = '0 0 31 2 0' + target.triggerSchedule_weekly = '0 0 31 2 0' + target.weekly_release_scmReferences = [] + target.disableJob = false }) // Fail if nothing was generated From 798ffa9b858fc258dfc524f375f78104ddb55979 Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 12:02:36 +0100 Subject: [PATCH 10/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- pipelines/build/regeneration/build_pipeline_generator.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index 30e60f4f1..2e07cab1f 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -280,10 +280,10 @@ node('worker') { generatedPipelines.add(config['JOB_NAME']) // config.load() loads into the current groovy binding, and returns "this", so we need to reset variables before next load of target - target.targetConfigurations = [] + target.targetConfigurations = {} target.triggerSchedule_nightly = '0 0 31 2 0' target.triggerSchedule_weekly = '0 0 31 2 0' - target.weekly_release_scmReferences = [] + target.weekly_release_scmReferences = {} target.disableJob = false }) From 372cdfdb222b646b744f0a499d24d41f6aca00de Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 12:09:19 +0100 Subject: [PATCH 11/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../regeneration/build_pipeline_generator.groovy | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index 2e07cab1f..113db0a48 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -201,12 +201,8 @@ node('worker') { config.put('disableJob', target.disableJob) } - if (enablePipelineSchedule.toBoolean()) { - try { - config.put('pipelineSchedule', target.triggerSchedule_nightly) - } catch (Exception ex) { - config.put('pipelineSchedule', '0 0 31 2 0') // 31st Feb, so will never run - } + if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_nightly')) { + config.put('pipelineSchedule', target.triggerSchedule_nightly) } if (useAdoptShellScripts.toBoolean()) { @@ -252,12 +248,8 @@ node('worker') { // Load weeklyTemplatePath. This is where the weekly_release_pipeline_job_template.groovy code is located compared to the repository root. This actually sets up the weekly pipeline job using the parameters above. def weeklyTemplatePath = (params.WEEKLY_TEMPLATE_PATH) ?: DEFAULTS_JSON['templateDirectories']['weekly'] - if (enablePipelineSchedule.toBoolean()) { - try { - config.put('pipelineSchedule', target.triggerSchedule_weekly) - } catch (Exception ex) { - config.put('pipelineSchedule', '0 0 31 2 0') // 31st Feb, so will never run - } + if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_weekly')) { + config.put('pipelineSchedule', target.triggerSchedule_weekly) } config.releaseType = "Weekly" From 04fd251bf9a68d62419799288f9234b37568eafa Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Fri, 11 Aug 2023 12:14:51 +0100 Subject: [PATCH 12/12] Ensure target is reset before loading a jdk pipeline config file Signed-off-by: Andrew Leonard --- .../build_pipeline_generator.groovy | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pipelines/build/regeneration/build_pipeline_generator.groovy b/pipelines/build/regeneration/build_pipeline_generator.groovy index 113db0a48..1914a05ee 100644 --- a/pipelines/build/regeneration/build_pipeline_generator.groovy +++ b/pipelines/build/regeneration/build_pipeline_generator.groovy @@ -197,12 +197,19 @@ node('worker') { config.put('targetConfigurations', target.targetConfigurations) - if (target.hasProperty('disableJob')) { + // hack as jenkins groovy does not seem to allow us to check if disableJob exists + try { config.put('disableJob', target.disableJob) + } catch (Exception ex) { + config.put('disableJob', false) } - if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_nightly')) { - config.put('pipelineSchedule', target.triggerSchedule_nightly) + if (enablePipelineSchedule.toBoolean()) { + try { + config.put('pipelineSchedule', target.triggerSchedule_nightly) + } catch (Exception ex) { + config.put('pipelineSchedule', '0 0 31 2 0') + } } if (useAdoptShellScripts.toBoolean()) { @@ -248,8 +255,12 @@ node('worker') { // Load weeklyTemplatePath. This is where the weekly_release_pipeline_job_template.groovy code is located compared to the repository root. This actually sets up the weekly pipeline job using the parameters above. def weeklyTemplatePath = (params.WEEKLY_TEMPLATE_PATH) ?: DEFAULTS_JSON['templateDirectories']['weekly'] - if (enablePipelineSchedule.toBoolean() && target.hasProperty('triggerSchedule_weekly')) { - config.put('pipelineSchedule', target.triggerSchedule_weekly) + if (enablePipelineSchedule.toBoolean()) { + try { + config.put('pipelineSchedule', target.triggerSchedule_weekly) + } catch (Exception ex) { + config.put('pipelineSchedule', '0 0 31 2 0') + } } config.releaseType = "Weekly"