Skip to content

Commit

Permalink
Ensure evaluation pipeline config load resets groovy binding before t…
Browse files Browse the repository at this point in the history
…he load (#790)

* Ensure evaluation pipeline config loaded correctly

Signed-off-by: Andrew Leonard <[email protected]>

* Ensure evaluation pipeline config loaded correctly

Signed-off-by: Andrew Leonard <[email protected]>

* Ensure evaluation pipeline config loaded correctly

Signed-off-by: Andrew Leonard <[email protected]>

---------

Signed-off-by: Andrew Leonard <[email protected]>
  • Loading branch information
andrew-m-leonard authored Aug 24, 2023
1 parent c103819 commit 1ded474
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions pipelines/build/regeneration/evaluation_pipeline_generator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,16 @@ node('worker') {
}
config.put('targetConfigurations', targetEvaluation.targetConfigurations)

println "[INFO] JDK${javaVersion}: loaded targetEvaluation configuration:"
println JsonOutput.prettyPrint(JsonOutput.toJson(targetEvaluation))

// if has a triggerSchedule_evaluation variable set then use it or default to '0 0 31 2 0'/never run
if (enablePipelineSchedule.toBoolean()){
config.put('pipelineSchedule', targetEvaluation.triggerSchedule_evaluation)
} else { // empty to not run
config.put('pipelineSchedule', '')
try {
config.put('pipelineSchedule', targetEvaluation.triggerSchedule_evaluation)
} catch (Exception ex) {
config.put('pipelineSchedule', '0 0 31 2 0')
}
}

// hack as jenkins groovy does not seem to allow us to check if disableJob exists
Expand Down Expand Up @@ -248,9 +253,11 @@ node('worker') {
}
config.PIPELINE = "evaluation-openjdk${javaVersion}-pipeline"
if (enablePipelineSchedule.toBoolean()) {
config.put('pipelineSchedule', targetEvaluation.triggerSchedule_weekly_evaluation)
} else { // empty string will never run
config.put('pipelineSchedule', '')
try {
config.put('pipelineSchedule', targetEvaluation.triggerSchedule_weekly_evaluation)
} catch (Exception ex) {
config.put('pipelineSchedule', '0 0 31 2 0')
}
}
config.put('targetConfigurations', targetEvaluation.targetConfigurations) // explicit set it to make things clear
config.weekly_release_scmReferences = targetEvaluation.weekly_evaluation_scmReferences
Expand Down Expand Up @@ -278,6 +285,13 @@ node('worker') {
}
// add into list
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 targetEvaluation
targetEvaluation.targetConfigurations = {}
targetEvaluation.triggerSchedule_evaluation = '0 0 31 2 0'
targetEvaluation.triggerSchedule_weekly_evaluation = '0 0 31 2 0'
targetEvaluation.weekly_evaluation_scmReferences = {}
targetEvaluation.disableJob = false
}
})

Expand Down
2 changes: 1 addition & 1 deletion pipelines/jobs/configurations/jdk17u_evaluation.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ targetConfigurations = [
]

// if set to empty string then it wont get triggered
triggerSchedule_pevaluation = 'TZ=UTC\n30 23 * * 2,4'
triggerSchedule_evaluation = 'TZ=UTC\n30 23 * * 2,4'
// if set to empty string then it wont get triggered
triggerSchedule_weekly_evaluation = 'TZ=UTC\n05 12 * * 7'

Expand Down

0 comments on commit 1ded474

Please sign in to comment.