The idea: On every push to a git repo, new Jenkins task build should be started. If the change is:
- new branch created - Jenkins will get the source, do some setup and run a Docker container, where this branch can be tested, etc.
- new push - Jenkins should rebuild the source
- branch deleted - Jenkins should delete the files that have been build, delete DBs, shut down containers, etc.
The setup:
- BitBucket repo with webhook pointing to the Jenkins URL
- Jenkins running on a local server with the BitBucket plugin and the task is to "Build when a change is pushed to BitBucket"
The problem:
When a branch is created/deleted the BitBucket webhook fires, and Jenkins is processing the request (So far, so good).
In the Jenkins logs I see: "Received commit hook notification for..." BUT the "BitBucket Hook Log" screen shows the following:
Polling SCM changes on master
Using strategy: Default
[poll] Last Built Revision: Revision
.....
.....
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
> git config remote.origin.url ...
Fetching upstream changes from ...
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.username ....
> git config --local credential.helper store --
> git -c core.askpass=true fetch --tags --progress ... +refs/heads/*:refs/remotes/origin/*
> git config --local --remove-section credential # timeout=10
Polling for changes in
Seen branch in repository ....
Done. Took 6.6 sec
No changes
So it's basically saying there are no changes, and the job is not running. If I made a code change and push that change to BitBucket, the job starts as expected and is running fine.
Any ideas how to force Jenkins to start a new build on branch creation/deletion?