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?
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'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.
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.
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).
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.
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
:
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
):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With