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:

  1. a developer branches off master, makes changes, creates a pull request
  2. another developer reviews the PR and eventually merges it into master
  3. some system (Jenkins or VSTS) detects that a PR was merged into master and…
    1. increments a version number stored in a file within the repo
    2. commits the version change back to master
    3. builds
    4. deploys

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:

  1. Build completed
  2. Code pushed
  3. 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.

enter image description here

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.