Race condition for dsl job queue() and dsl script security
See original GitHub issueHi,
I have multiple .yaml files in my CASC_JENKINS_CONFIG folder. One primarily does all the heavy lifting including disabling dsl security, e.g.:
security:
globaljobdslsecurityconfiguration:
useScriptSecurity: false
In a separate CASC_JENKINS_CONFIG file I am creating a seed dsl job that pulls in more dsl groovy scripts over git, e.g.:
jobs:
- script: >
pipelineJob('dsl-seed-job') {
definition {
cps {
script('''node {
stage('some_config') {
git branch: SOME_BRANCH, credentialsId: SOME_CREDENTIAL_ID, url: SOME_URL
jobDsl targets: 'job_dsl/*.groovy'
..................................
}
queue('dsl-seed-job')
Because this job itself executes wildcard jobDsl scripts, script security must be disabled before it is queued in order for it to run unattended. But from the jenkins log file, it unfortunately consistently queues the job just before the script security parameter is updated, and so it fails to actually run without manual permission / intervention:
Oct 24, 2018 6:41:17 PM javaposse.jobdsl.plugin.JenkinsJobManagement createOrUpdateConfig
INFO: createOrUpdateConfig for dsl-seed-job
Oct 24, 2018 6:41:18 PM hudson.plugins.promoted_builds.integrations.jobdsl.PromotionsExtensionPoint notifyItemCreated
INFO: Creating promotions for dsl-seed-job
Oct 24, 2018 6:41:18 PM io.jenkins.plugins.casc.Attribute setValue
INFO: Setting javaposse.jobdsl.plugin.GlobalJobDslSecurityConfiguration@39f2b7fe.useScriptSecurity = false
If I go login into CasC interface within jenkins management after the container has started and hit ‘Reload Existing Configuration’ without making any yaml changes, the seed job successfully queues.
Is there a way to specify a prerequisite change in CasC so this doesn’t happen, or enforce lexicographical filename order for yaml changes? My current workaround is to use a Datetime() delta and cron schedule the seed job to run in 1 minute which gives the config enough time to finish updating, but it feels like a sloppy workaround.
- Jenkins version 2.138.2
- Plugin version 1.11
- docker jenkins/jenkins:lts
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
@casz, Hi, just found that with JCasC v.1.22 and Job-DSL v.1.74 this issue still exists. I use freestyleJob to create ‘Process Job DSL’ step. On first clean startup queue() part does not create new build, but if I reload configuration it’s OK. I’m running jenkins/jenkins:lts in Docker and have single .yaml JCasC config file, with the following code:
And then:
System log:
Just linking #280 🙈