Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Jenkins, does a multibranch pipeline support Git tags?

Using a multibranch pipeline I see a list of all my Git branches.

However, I would expect git tags to appear in the list also but they don't seem to be listed.

Is this expected behaviour or is this possibly a config issue? Are tags supported? If tags are not supported, is there a plugin that can work in harmony with the multibranch pipeline to support tags?

like image 614
danday74 Avatar asked Feb 25 '17 07:02

danday74


People also ask

What do Multibranch pipelines enable?

The Multibranch Pipeline project type enables you to implement different Jenkinsfiles for different branches of the same project. In a Multibranch Pipeline project, Jenkins automatically discovers, manages and executes Pipelines for branches which contain a Jenkinsfile in source control.

What is a Multibranch pipeline in Jenkins?

What's a Jenkins Multibranch Pipeline? A multibranch job is simply a folder of pipeline jobs. For every branch you have, Jenkins will create a folder. So instead of creating a pipeline job for each of the branches you have in a git repository, you could use a multibranch job.

What is the purpose of a Multibranch pipeline?

A multibranch pipeline is a pipeline that has multiple branches. The main advantage of using a multibranch pipeline is to build and deploy multiple branches from a single repository. Having a multibranch pipeline also allows you to have different environments for different branches.

How do I pass tag name in Jenkins pipeline?

In the "Git Repository" section of your job, under the "Source Code Management" heading, click "Advanced". Under "Branches to build", "Branch specifier", put */tags/<TAG_TO_BUILD> (replacing <TAG_TO_BUILD> with your actual tag name).


2 Answers

I think the problem you're facing is described in Jira issue JENKINS-34395.

As far as I understand, the multibranch plugin does not support tags and is focused only in building branches. The workaround suggested is to have two separate builds, one for a normal branch build and second (seems not configured with a Jenkinsfile) to build a tag.

Update, 14.04.2021:

Jenkins does support tag builds now as described in this post but tag builds may not run automatically because of build strategy. Refer to this comment for some details.

like image 101
Ivan Stanislavciuc Avatar answered Oct 25 '22 15:10

Ivan Stanislavciuc


Actually Jenkins multibranch pipeline doest support build on tag.

In Jenkins go in configuration of your multibranch pipeline.

In Branch Sources -> Behaviors -> click on Add and select Discover tags:

Jenkins multibranch pipeline config for tags

In the screenshot above, I listen branches develop, main, feature/* and I also filter tags in the format vX.Y.Z.

Once you validate this configuration you will see two tabs in the main view of the pipeline (branches and Tags):

Jenkins multibranch pipeline view branches and tags

like image 20
Thomas Avatar answered Oct 25 '22 15:10

Thomas