Job DSL Plugin 1.77
Given the current (and arguably awkward) behavior of Pipeline jobs (JENKINS-50365), several values, such as triggers and parameters, are only reloaded after the job runs.
This behavior conflicts with the fact that Job DSL scripts completely overwrite trigger definitions created by the Pipeline script.
While trying to keep a fully automated job maintenance routine, we load Job DSLs using the JCasC plugin. Our Job DSLs are minimal and define only a directive to load the Jenkinsfile from a remote SCM.
In practice, we are unable to keep trigger and parameter definitions in the Jenkinsfile. Everytime a clean Job DSL is reloaded, all triggers and parameters created by the Jenkinsfile are lost.
The only workaround we found is to keep triggers and parameters defined outside the Jenkinsfile, in the Job DSL.
- Install Job DSL Plugin
- Install JCasC plugin (or use a seed job to load DSLs)
- Create a Job using DSL that loads a remote Jenkinsfile from SCM
- Define job triggers in the Jenkinsfile
- Define job paramteres in the Jenkinsfile
- Run the job once
- Check job configuration (triggers and parameters will be there)
- Reload the DSL
- Check job configuration (triggers and parameters will be lost).