How to automatically triggers Jenkins job when there is a Git tag push to Bitbucket server or git tag created from a branch in BB?

I have a multibranch pipeline configured, Jenkins job triggers whenever there is code commit, PR, merge. The automatic trigger works as expected but issue is when there is a git tag push or when a git tag is created from a branch, it does not automatically trigger the Jenkins job. The only way to trigger it is by manual build from Jenkins UI.

If you click build in Jenkins UI, it will trigger and start the build process but will never trigger when you push git tag.

Is this a kind of limitation or how can I resolve this issue?

1 Like

Hi @ayodeletolu12 and welcome to this community :wave:

Please have a look at this answer and let us know if that works for you.

Basically, it asks you to install the Basic Branch Build Strategies plugin and activate the building of tags for the pipeline.

@poddingue thanks for the feedback. However, we have the Basic Branch Build Strategies plugin installed and activated on my environment but still didnā€™t work.

From the scan multibranch pipeline, the log shows that tags are discovered but no automatic build triggered

Checking tag ***************
      ā€˜Jenkinsfileā€™ found
    Met criteria
Changes detected: ****************** (null ā†’ ***********************************)
No automatic build triggered for TagName

Is this kind of limitation?

1 Like

I donā€™t think so. :thinking:

Let me try it on my Jenkins instance.

I havenā€™t been able to test yet, but before I do, could you please tell me if your tags are annotated?
I was discussing your issue with Damien Duportal a few minutes ago, and he told me one of the reasons your tags arenā€™t built could be that they are too old.

Let me try to explain what I think I understood: whenever you create a draft release, it will be associated with the date you created it. When you finalize your release and point to a certain commit, the tag is created with the date the commit was madeā€¦ And if you made this commit 6 days ago, your tag will also be 6 days oldā€¦ unless you annotate it, so that it is 0 days old.
Most of the time, the default tag build configuration is 3 days, so could you please check how old your tags are, and if they are annotated? Iā€™m not familiar with BitBucket, only GitHub.

That could be the reason why the plugin does not pick your tags, or notā€¦
Most of the time, itā€™s not very verbose when it finds an ā€œoutdatedā€ tag.

I do hope I did not butcher too much Damienā€™s explanation.

1 Like

I am very sorry that I havenā€™t given you feedback since the last time you asked me to carry out some action plans.

It worked when I annotate my tags, the build was automatically triggered after pushing it.

example below, on how to annotate tag.

  1. Creating an annotated tag in Git is simple. The easiest way is to specify -a when you run the tag command:
**$ git tag -a v1.4 -m "my version 1.4"**

Git - Tagging (git-scm.com)

Thank you so much. You were super helpful.

1 Like

No problem with the delay.

Thanks a lot for your feedback. :pray: