Let's have a seed job in Jenkins Job DSL Groovy which generates a pipeline this way:
pipeline {
agent any
stages {
stage("DSL") {
steps {
jobDsl scriptText: """pipelineJob("test-pipeline-generated") {
definition {
cps {
script 'pipeline { agent(any); triggers{ cron("H/2 * * * *") }; stages { stage("Some") { steps { echo "Working ..." } } } }'
}
}
}
"""
}
}
}
}
It generates a pipeline job which has to be triggered manually for the first time to process triggers
definition and everything works fine. However, when the seed job is triggered again it overwrites the pipeline job definition and triggers are gone again. This means that seed job disables all such jobs.
Does anybody know if there is any solution for it?
We would like to keep triggers there and if there are changes in the pipeline it will be processed after the first run. We would like to not specify triggers in job DSL because users are used to specify them in the pipeline definition.