jenkinsci / configuration-as-code-plugin

Jenkins Configuration as Code Plugin
https://plugins.jenkins.io/configuration-as-code
MIT License
2.7k stars 722 forks source link

Scan of multibranch pipeline always triggers every detected branch after Jenkins restart #339

Closed smueller18 closed 6 years ago

smueller18 commented 6 years ago

I defined multibranch pipeline jobs with the job configuration (like https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/plugin/src/test/resources/org/jenkinsci/plugins/casc/SeedJobTest.yml). The creation of the jobs works fine, but whenever I restart Jenkins and the next multibranch pipeline scan is triggered, all jobs are being executed even if the job definition and the source code has not changed. It does not matter how Jenkins is restarted (docker restart or call of http://localhost:8080/safeRestart), the behavior is always the same. When I remove the jobs section in the yml, a scan after restart does not trigger jobs for unchanged branches.

Jenkins version: 2.130 CasC version: 0.9-alpha

Novakov commented 6 years ago

I also had this problem - if you look at the multibranch scan log I guess there will be a lot of messages like 'Takeover for ... by source #1 from source that no longer exists'. That message led me to https://issues.jenkins-ci.org/browse/JENKINS-43693 and adding id = some_unique_name into my Job DSL.

It seems that during every Jenkins start (or configuration reload) branch source is recreated by setting id job can recognize that it is the same source

smueller18 commented 6 years ago

Thank you very much, that solved my problem.