Jenkins – failed to find any usable tags for the pipeline in mode

Problem

While you are building a Jenkins pipeline job through Jenkins for the first time, you may encounter such error “failed to find any usable tags for the pipeline in pipelineMode“. This error may arise due to the fact that you have created the branch recently and there is no tag version yet released for this branch.

The reason which you will find officially behind such issue is as follows:

This error is most likely to occur on a release/relfix/hotfix/hotdefect branch pipeline and is caused when a previous job has failed to tag the repository causing a version mismatch between last tag and branch Major minor versions. This can be fixed by identifying the job which failed to tag and then manually applying the missing tag via the Gitbash console.

Solution

As you are building the Jenkins pipeline job first time for this particular branch and there is no tag version yet released, so you can manually create an initial tag version from the Gitbash console.

Here is the commands which you need to execute from the Gitbash console. First you checkout the branch for which you want to create tag version. Generally, you need to checkout the branch which is failing in Jenkins build.

$ git checkout <branch>
$ git pull origin <branch>

Create tag version for the branch:

$ git tag <tag>

For example, $ git tag -a "0.1.0.Develop", where 0.1.0.Develop is the tag version for the develop branch and -a parameter is used to add the tag version.

This will ask for the commit message in a popup window. Press i to change the editor mode in insert and once you finished typing the commit message (for example, initial tag version), press Esc key and type :wq to save and exit the editor.

Once the tag version is created you need to push the tag to the origin:

$ git push origin <tag>

For example, $ git push origin "0.1.0.Develop".

Now you can find the tag version under the Tags tab of the Github repository:

git tag version

Once the tag version created for the required branch, next time when you run the same pipeline job, the job will be successfully executed.

Leave a Reply

Your email address will not be published. Required fields are marked *