Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure evaluation pipeline config load resets groovy binding before the load #790

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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