Jenkins Build With Tags

Today I learned how to set your build process to work off of git tags for builds versus commits into master.

Under the “Source Code Management” section click Advanced… under your credentials and make sure that you have this in your Refspec field: +refs/tags/*:refs/remotes/origin/tags/*. Then for your branches to build, have a branch specifier like this */tags/v*-*. This will build any tag that starts with a v and has a - in it. The idea here is to have tags that look like this v0.1.0-alpha go down a different flow.

"Build tags with dashes"

To then have your other tags that do not have a dash in them picked up in another build process you’ll need to tweak it a bit and set it up like this:

"Build Tags without Dashes"

Notice how I have added the inverse strategy option from “Additional Behaviours”. With this I also needed to add the */* specifier branch so as to not have the build pick up any other feature branches or other items being added in.