Reputation: 389
I have a job BuildApp with a build (MultiJob Phase) that calls another job BuildAppJar to build a jar. In job BuildApp, "Build only if SCM changes" is set to true. I am expecting the job BuildAppJar will build a jar file with the latest commit because Job BuildApp is configured to build when SCM changes. But this is not happening. Instead I am getting this log saying "subjob has no changes since last build." Why is it so? Any idea? Isn't Jenkins supposed to build with the latest code commit? I am using Git.
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
>> Job status: [BuildAppJar] subjob has no changes since last build.
Thanks.
Upvotes: 2
Views: 8509
Reputation: 131
It works! The problem is - Jenkins can't detect changes of subjob branch. You must perform, for each subjob, poll SCM or notify Jenkins by using WebHook.
Example of my usage with WebHook:
In your subjob projects Configs:
section Build Triggers:
section Build Environment:
Into GIT project, add WebHook located at Settings -> WebHooks.
<jenkins_url>/gitlab/notify_commit
In Multijob Configs:
section Multijob specific configuration :
section Build Triggers:
Commit you changes with message that contains word [ci-skip] to skip automatic build.
Now you can push changes to your branch, Jenkins will be notified and build skipped. After that, run your MultiJob.
Upvotes: 0
Reputation: 2688
This may be because of this bug (I believe both are the same problem):
https://issues.jenkins-ci.org/browse/JENKINS-50168
https://issues.jenkins-ci.org/browse/JENKINS-55524
The symptom is that Jenkins is polling two repositories, but doesn't check the correct one for changes. Add your "git polling log" (or, depending on your plugin, whatever log appears at the bottom of the list above your build history) for confirmation. I have not found a workaround.
Webhooks (gitlab, bitbucket, or whatever) don't actually cause Jenkins to build a particular commit - the webhook just notifies Jenkins that something has changes, and Jenkins polls the repository to see whether that change should trigger a build. In my case, Jenkins receives the hook, polls the repo, then polls another repo (also used by that job, but rarely updated) and checks it for changes. So you need to have "Build when a change is pushed to GitLab" and "Poll SCM" both checked.
For a long list of other possibilities, check https://issues.jenkins-ci.org/browse/JENKINS-17614
Upvotes: 1