I want to configure jenkins so that it starts building if a new tag is released in any branch of an git repository. How do I configure this behaviour?
Triggering:
Thanks for any help
Please note that the approach in the answer provided by stanjer doesn't make Jenkins trigger builds on new tags if they point to commits that were built before. For example, you tag release v1.0.0 (to make jenkins deploy this release), then on the future you have to rollback to v1.0.0, tagging its commit again, but with v1.0.0-rollback, Jenkins won't deploy your rollback because it will check the hash the tag points to, not the hash of the tag itself.
In summary, jenkins will only build new tags if they point to commits that are not tagged already, and this is currently not tweakable.
It would be awesome if one could use Jenkins as a CD tool working with tags for deploys and rollbacks.
More info here https://groups.google.com/forum/#!msg/jenkinsci-users/mYxtDNMz1ZI/xbX9-xM9BQAJ
Previous doesn't work for me. In my case works refspec in single quotes:
Refspec: '+refs/tags/*':'refs/remotes/origin/tags/*' Branch Specifier: **/tags/**
I have Jenkins 2.120. To make job work which is triggered by tag need to do the following steps:
create job with:
Refspec: '+refs/tags/*':'refs/remotes/origin/tags/*'
Branch Specifier: **/tags/**
Run build
Reconfigure the same job to parameters:
Refspec: '+refs/tags/*':'refs/remotes/origin/tags/*'
Branch Specifier: **
Run build
Reconfigure the same job to parameters:
Refspec: '+refs/tags/*':'refs/remotes/origin/tags/*' Branch Specifier: **/tags/**
Run the build
Only after this magic steps, when I tag the branch it automatically trigger Jenkins
Combined @albertski and @Sergey answers works for me.
Path: Jenkins > {YourJob} > Configure > Pipeline > Definition(Pipeline script from SCM) > SCM(Git)
Options:
Repositories > Advanced... > Refspec +refs/tags/v*:refs/remotes/origin/tags/v*
Branches to build > Branch Specifier (blank for 'any') **/tags/v*
Set v* if you want build tags started with v, such as v0.1.0, v1.0.5...