Continuous Delivery with VSTS and Jenkins
Source – stackoverflow.com
I’m trying to get continuous delivery going with Jenkins (building, deploying) and VSTS (source control). This is the desired workflow:
- a developer branches off master, makes changes, creates a pull request
- another developer reviews the PR and eventually merges it into master
- some system (Jenkins or VSTS) detects that a PR was merged into master and…
- increments a version number stored in a file within the repo
- commits the version change back to master
I was using Service Hooks within VSTS to detect the merge to master and execute a Jenkins task. VSTS has 3 hooks I can use:
- Build completed
- Code pushed
- Pull request merge commit created
I was under the impression that the third option would only occur when a PR was merged, but that’s not the case. Any additional commits to the branch, while it’s associated with the PR triggers the hook. This causes a bunch of unnecessary deployments.
I figured I could make Jenkins detect changes within VSTS. There’s a “Poll SCM” option, which takes a cron-like schedule. The utterly confusing thing is, it doesn’t appear that I can configure what exactly will be polled every X minutes (which repo, which branch).
What are my options here to trigger Jenkins tasks only when a PR is merged to master? I would use the VSTS “Code pushed” Service Hook, but it goes into an infinite loop because Jenkins pushes to master when it increments the version.