Bamboo Tag Triggering
Asked by Bongani Buthelezi:

Hello,

We are currently running on Bamboo version 9.6.0 ,but have been struggling to get the Tag trigger to work as expected with our Bitbucket Cloud repo following this documentation (<https://confluence.atlassian.com/bamboo/tag-triggering-1031180298.html>)

Now I understand that the triggering will not work if done on the UI and needs to be pushed via CLI.  

Is it however mandatory to have the webhooks enabled for the tag triggers to work or is there something else we're missing.

<br />

Regards,

Bongani


Answers:
author: Shashank Kumar
body: Hello Bongani,

Welcome to Atlassian community.

I just did a quick testing on my Bamboo version 9.2.1 where I created a tag on Bitbucket cloud from the GUI and didn't create any Webhooks and the Build was trigerred for me, although it took sometime ard \~5 mins for the build to be trigerred.

In the logs you can see the below message

```
2024-04-30 11:22:22,730 INFO [10-BAM::PlanExec:pool-13-thread-3] [TagBuildAction] Tag build for planKey=SHA-KEY, tagAndRevision=abcd 6d547000358cf446405ca79b13ebdb43b0ae7467
```

<br />

Bamboo tag detection follows the branch detection interval which is 5 minutes by default and adds a time 50% delay to that time so it won't compete with the branch check activities, meaning that tag detection will be running every 300 seconds with a delay of 150 seconds.

My Trigger looks like below

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321291i545A3BDD683A710E/image-size/large?v=v2&px=999 "image.png")Can you retry these setting and let me know if this works for you, if not do you see any error in the logs?

Regards,

Shashank Kumar

**\*\*please don't forget to Accept the answer if your query was answered\*\***

comments: author: Bongani Buthelezi
body: Hi Shashank

Thanks for your response. I just changed my settings in the tag trigger to match yours as suggested and still the build was not triggered.  

I'm not quite sure however which logs I need to check for errors since the build details are not on the plan history on Bamboo.


author: Shashank Kumar
body: Hello Bongani,

You can start by looking at **\<bamboo-home\>logs\>atlassian-bamboo.log** file to check if you are getting any errors.

For testing create a new tag and monitor the above logs to see if you see any errors regarding tag detection.

Regards,

Shashank Kumar


author: Bongani Buthelezi
body: Hi Shashank,

<br />

Apologies for the delayed response. I actually tried tailing the logs from both our Bamboo host server and the agent that we currently have the plan running on and no errors regarding the "Tag detection" or any other errors related to it are populating in there.  

The only ERROR I could see was the ConnectionException one below but I dont really think this is related to anything with the Tag issue.  

2024-05-03 13:27:21,268 ERROR \[xxxxxxxxxxxxxxxxxxxxxx\] \[Promise\] \<\<chan#0 / chanreq for env\>\> woke to: net.schmizz.sshj.connection.Connect  
ionException: Request failed  

Respectfully,

Bongani Buthelezi


author: Bongani Buthelezi
body: Im assuming something may have changed on the 9.6.0 version. I might have to also try on the same version 9.2.1 to see if the problem does persist on my side as well.


author: Shashank Kumar
body: Hi Bongani,

We may try to enable few more Debug logs in Bamboo to check the issue further, can you confirm one thing to me.

If you trigger the Build manually, is Bamboo able to checkout the Bitbucket Cloud repo and do the Build?

Regards,

Shashank Kumar


author: Bongani Buthelezi
body: Yes, it seems so because I ran the plan manually following this documentation (<https://confluence.atlassian.com/bamboo/running-a-plan-build-manually-289276898.html>) for the customized manual build using one of the release tags I have attached on the branch in Bitbucket and it ran successfully.

We also have an SSH task included in the build that does a "git clone" on the repo Cloud.  

Regards,

Bongani


author: Shashank Kumar
body: Thanks for confirming this, this is little tricky why tag triggering is not working!

Can you confirm one more thing for me before we start enabling Debug logs, please run the below query and let me know if the tag for which you are trying to build exists in the DB or not?

**select** **\*** **from** vcs_tag **where** **name** **=**'tag_name'

Replace tag_name with the name of the tag.

Regards,

Shashank Kumar


author: Bongani Buthelezi
body: Thanks for the heads up.  
The VCS_TAG table is empty from what I can see. I ran **select \* from** from the table.

Regards,

Bongani


author: Shashank Kumar
body: Hello Bongani,

Thanks for confirming this

Bamboo will keep track of all tags from a VCS repository and store them on the VCS_TAG table in the database. When Bamboo scans for tags it compares with the data already present on that table and if there is a match, no triggers are actioned as it understands the tag is already present and was "already triggered" in the past.

If the tag entry is removed from the database, Bamboo will treat it as it was a new tag.

In your case it is empty which means Bamboo is not able to read the tags for this Bitbucket cloud repository.

Let's check couple of things.

1. Just make sure you have done all the settings as per [Tag Trigerring](https://confluence.atlassian.com/bamboo/tag-triggering-1031180298.html)

2. If all steps in 1 is okay and still the Tag trigerring is not working you can try one of manual Tag triggering and let me know if this works.

To perform a **Run Customised** build:

1. From any UI screen where the **Run** dropdown is present for a particular plan, e.g. when viewing or editing a plan:
2. **Run \>\> Run Customised**
3. Enter the tag name in the **Revision** field

Let me know the results of the above 2

Can you also check if by any chance you have the below property configured in your setenv.sh or setenv.bat file

    atlassian.bamboo.tag.detection.disable=true 

Regards,

Shashank Kumar


author: Bongani Buthelezi
body: It doesn't look like its updating the VCS_TAG table at all from what I can see, but below is my response to your suggestions.

1. Everything looks good from the Tag Triggering page.

2. I tried the manual customised run and the plan runs successfully when I use the same tag I attached on the Bitbucket Cloud Repo in the revision field.

3. I have also verified that the file setenv.sh doesn't have the tag detection disabled.

Respectfully,

Bongani


author: Shashank Kumar
body: Hello Bongani,

With the manual test we can confirm that Bamboo is able to connect to Bitbucket cloud and even read the tags and do the build.

I think you'll need to add the below Debug logs in Bamboo, refer the attached to understand how to do it [Configuring the level of logging on the Bamboo server](https://confluence.atlassian.com/bamboo/logging-in-bamboo-289277239.html#LogginginBamboo-ConfiguringthelevelofloggingontheBambooserver)

* com.atlassian.bamboo.plugins.git=ALL
* com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager=DEBUG
* com.atlassian.bamboo.plan.branch.BranchDetectionServiceImpl=DEBUG

**WARNING** : DEBUG logs may be very verbose!

You can add the above Debug logs and immediately create a new tag in Bitbucket cloud and monitor the below logs in Bamboo, it will give you information about why tag trigger is not working

\<bamboo-home\>logs\>atlassian-bamboo.log

Do let me know if you get anything related in the logs.

You can remove these Debug logs 15-20 mins after you have created the Tag

Regards,

Shashank Kumar


author: Bongani Buthelezi
body: Hi Shashank,  

I manged to add the logs as explained and the error I got when I add a new tag is as per below just can't really determine what needs to be done to resolve this.  

```


2024-05-09 07:51:53,126 ERROR [22-TagDetectionBackgroundThread:pool-23-thread-2] [TagDetectionServiceImpl] An exception occurred when trying to read and handle tags from repository
com.atlassian.bamboo.repository.RepositoryException: Use NativeGitHelper for getting tags list
at com.atlassian.bamboo.plugins.git.v2.GitTagsHandler.getAllTagsFromRepository(GitTagsHandler.java:65) ~[?:?]
at com.atlassian.bamboo.plugins.bitbucket.v2.BitbucketCloudTagsHandler.getAllTagsFromRepository(BitbucketCloudTagsHandler.java:20) ~[?:?]
at com.atlassian.bamboo.tag.service.TagDetectionServiceImpl.lambda$detectTagsForRepository$1(TagDetectionServiceImpl.java:88) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.tag.service.TagDetectionServiceImpl.lambda$useVcsTagHandler$18(TagDetectionServiceImpl.java:274) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:115) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.tag.service.TagDetectionServiceImpl.useVcsTagHandler(TagDetectionServiceImpl.java:275) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.tag.service.TagDetectionServiceImpl.detectTagsForRepository(TagDetectionServiceImpl.java:87) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.tag.service.TagDetectorThread$1.run(TagDetectorThread.java:26) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.plugin.BambooPluginUtils$Runnable.call(BambooPluginUtils.java:108) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.plugin.BambooPluginUtils$Runnable.call(BambooPluginUtils.java:101) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.plugin.BambooPluginUtils.callUnsafeCode(BambooPluginUtils.java:55) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.tag.service.TagDetectorThread.run(TagDetectorThread.java:50) ~[atlassian-bamboo-core-9.6.0.jar:?]
at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) ~[atlassian-bamboo-api-9.6.0.jar:?]
at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) ~[atlassian-bamboo-api-9.6.0.jar:?]
at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) ~[atlassian-bamboo-api-9.6.0.jar:?]
at com.atlassian.bamboo.security.ImpersonationHelper.lambda$makeRunnableWithSystemAuthority$0(ImpersonationHelper.java:38) ~[atlassian-bamboo-api-9.6.0.jar:?]
at java.lang.Thread.run(Thread.java:829) ~[?:?]
Caused by: java.lang.UnsupportedOperationException: Use NativeGitHelper for getting tags list
at com.atlassian.bamboo.plugins.git.JGitOperationHelper.getTagsForRepository(JGitOperationHelper.java:404) ~[?:?]
at com.atlassian.bamboo.plugins.git.v2.GitTagsHandler.getAllTagsFromRepository(GitTagsHandler.java:53) ~[?:?]
```


author: Shashank Kumar
body: Hello Bongani,

I guess you have found something substantial which tells about the problem, see the error message below \> **Use NativeGitHelper for getting tags list**

```
ERROR [22-TagDetectionBackgroundThread:pool-23-thread-2] [TagDetectionServiceImpl] An exception occurred when trying to read and handle tags from repository
com.atlassian.bamboo.repository.RepositoryException: Use NativeGitHelper for getting tags list
```

I think the problem is with the GIT which you are using, looking at the stack trace I can see you are using **JGIT** , which is not supporting the operations which Bamboo is doing during the tag triggering. Also Bamboo 9.6 does not support **JGIT**

```
com.atlassian.bamboo.plugins.git.JGitOperationHelper.getTagsForRepository(JGitOperationHelper.java:404) ~[?:?]
at 
```

Can you Install native GIT with version 2.35 and later on your Bamboo server and see if this problem is solved, if you are using remote agents then the Git Version should be updated there as well.

Once you Install Native GIT, please check if this is listed in **?? \> Overview \> Server Capability**page

Let me know if this solves your problem

Regards,

Shashank Kumar


author: Bongani Buthelezi
body: Hi Shashank,

I have now installed the native Git on both the Bamboo server and our agent and also verified from the Server capabilities that GIT is successfully installed as mentioned.

1. The VCS_TAG table on the DB now has been updated with all the relevant tags that I have attached on the plan branch on bitbucket.  

2. I'm not sure if its processing all the tags hence its taking time but I don't see any errors relating to the tag detection anymore but the builds on Bamboo dashboard don't seem to be updating with any runs just as yet.

```
2024-05-09 11:12:36,530 INFO [http-nio-8085-exec-11 url: /agentServer/GetFingerprint.action] [RemoteAgentManagerImpl] A remote agent is loading on xxxxxxxxxxxxxxx (xxxxxxxxxxxxx).
2024-05-09 11:14:23,114 DEBUG [scheduler_Worker-10] [BranchDetectionServiceImpl] Request for detecting branches for repository: 753665
2024-05-09 11:14:23,114 DEBUG [11-BranchDetectionBackgroundThread:pool-12-thread-3] [BranchDetectionServiceImpl] Detecting branches for repository 753665
2024-05-09 11:14:23,117 DEBUG [11-BranchDetectionBackgroundThread:pool-12-thread-3] [BranchDetectionServiceImpl] Found following plans using repository 753665:
2024-05-09 11:14:23,118 DEBUG [11-BranchDetectionBackgroundThread:pool-12-thread-3] [BranchDetectionServiceImpl] No plan with automatic branch management is using repository 753665 as default repository
2024-05-09 11:16:53,132 DEBUG [22-TagDetectionBackgroundThread:pool-23-thread-1] [GitCommandProcessor] Running in /: [/usr/bin/git version]
2024-05-09 11:16:53,132 DEBUG [22-TagDetectionBackgroundThread:pool-23-thread-1] [GitCommandBuilder] GIT_SSH_VARIANT="ssh" SSH_ASKPASS="/bin/echo"
2024-05-09 11:16:53,146 DEBUG [22-TagDetectionBackgroundThread:pool-23-thread-1] [NativeGitOperationHelper] beforeRepositoryAccess is writing to credentials file: /opt/atlassian/bamboo/atlassian-bamboo-9.6.0/temp/gitCredentialsxxxxxxxxxxxxxxxxxxxx.tmp
2024-05-09 11:16:53,148 DEBUG [22-TagDetectionBackgroundThread:pool-23-thread-1] [GitCommandProcessor] Running in /opt/atlassian/bamboo/atlassian-bamboo-9.6.0/temp: [/usr/bin/git -c credential.helper= -c 'credential.helper=store --file=/opt/atlassian/bamboo/atlassian-bamboo-9.6.0/temp/gitCredentials4925885322607312541.tmp' ls-remote --tags {bitbucketcloud_repo_url}]
2024-05-09 11:16:53,148 DEBUG [22-TagDetectionBackgroundThread:pool-23-thread-1] [GitCommandBuilder] GIT_SSH="/opt/atlassian/bamboo/atlassian-bamboo-9.6.0/temp/bamboo-ssh.2958cbb8.sh" GIT_SSH_VARIANT="ssh" SSH_ASKPASS="/bin/echo"
2024-05-09 11:16:54,842 DEBUG [550:StdoutHandler [/usr/bin/git]] [RemoteTagsOutputHandler] Processing line: 03b3fbfb2177727749eea04dcfbeb861f052d55b refs/tags/23.3.3
2024-05-09 11:16:54,842 DEBUG [550:StdoutHandler [/usr/bin/git]] [RemoteTagsOutputHandler] Processing line: 763bf460db31669478fc3caa2c6fccbd16029d5d refs/tags/23.3.3^{}
2024-05-09 11:16:54,842 DEBUG [550:StdoutHandler [/usr/bin/git]] [RemoteTagsOutputHandler] Found annotated tag refs/tags/23.3.3 for revision 03b3fbfb2177727749eea04dcfbeb861f052d55b
2024-05-09 11:16:54,843 DEBUG [550:StdoutHandler [/usr/bin/git]] [RemoteTagsOutputHandler] Processing line: 445919b61a48fb9686308f9f83696bab48507a46 refs/tags/24.2.1.1
```

<br />

Thanks yet again for your assistance.  

Regards,

Bongani


author: Bongani Buthelezi
body: I just needed to wait abit longer but I just tested now again with a new tag and the build worked just fine.

```

2024-05-09 14:47:55,840 INFO [15-BAM::PlanExec:pool-16-thread-2] [TagBuildAction] Tag build for planKey=DEV-RPB, tagAndRevision=abcde 88c50a6a225817edd7ba2aa93470a67b448c6725
```

<br />

Thanks again Shashank

Respectfully,

Bongani Buthelezi


author: Shashank Kumar
body: Hey Bongani,

Glad to know that it worked out!

Cheers

Shashank Kumar