What the correct way of tagging a build with the Jira version when using Jira's Release with Build
Asked by Robert Turner:

I have finally got around to trying to make the "Release with Build" Jira functionality work with our Bamboo builds for tagging a release. However, I cannot seem to get it to tag the build with the Jira release name/version even though I think I have set things up correctly.

Environment:

* JIra Cloud
* Bamboo 7.0.4

I have a Build Plan, with two stages, with the second stage set as a manual stage for "Tag and Release".

Within the second stage, I have a "Repository Tag" Task configured, with the relevant repository, and the Tag name set to "RELEASE-${bamboo.jira.version}".

After triggering the build from Jira, using the "Release with new build" functionality (after working around the very limited build selection by modify the HTML value for the check box to the correct build), the build stage was correctly triggered and ran.

The source was tagged, but the tag name was literally "RELEASE-${bamboo.jira.version}".

Here's an extract from the build log for the manual stage:

```
simple	24-Jun-2020 20:08:48	Starting task 'Tag the source code with the Jira version details' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.tagging'simple	24-Jun-2020 20:08:50	Warning: Permanently added '[127.0.0.1]:44649' (RSA) to the list of known hosts.simple	24-Jun-2020 20:09:15	Git LFS: (0 of 0 files, 85 skipped) 0 B / 0 B, 790.86 MB skipped               simple	24-Jun-2020 20:09:17	To ssh://127.0.0.1:44649/XXXXX/XXXXXXX.gitsimple	24-Jun-2020 20:09:17	 * [new tag]             RELEASE-${bamboo.jira.version} -> RELEASE-${bamboo.jira.version}simple	24-Jun-2020 20:09:17	Git LFS: (0 of 0 files, 85 skipped) 0 B / 0 B, 790.86 MB skipped               simple	24-Jun-2020 20:09:17	Finished task 'Tag the source code with the Jira version details' with result: Successs
```

As you can see, it created a nice tag, with a not so nice name, and certainly not the intended name.

I should also add that I have other "Repository Tag" Task configured using other Bamboo build variables, and they substitute the variables in without issue.

**And now my question:** Any ideas what I am doing wrong, or if this functionality works properly?

Thanks,

Robert


Answers:
author: Robert Turner
body: So after working with Atlassian Technical Support a bit, and doing the logical thing at their suggestion (which I didn't think of) and adding a "Dump variables to log", I discovered the variables are not named as documented when triggering the manual stage.

What I found was that the variables should be named:

```
bamboo.triggerReason.jiraBaseUrl
bamboo.triggerReason.jiraProjectKey
bamboo.triggerReason.jiraProjectName
bamboo.triggerReason.jiraUserDisplayName
bamboo.triggerReason.jiraUsername
bamboo.triggerReason.jiraVersion
bamboo.triggerReason.jiraVersionId
```

Once I switch my tag name to use "${bamboo.triggerReason.jiraVersion}" things now behave as expected (ignoring the lack of builds to choose from when triggering).

I'm not sure if this is what Atlassian intends for people to do or not -- hopefully the support team will let me know soon.

But I'm sharing this information in the hopes that it helps someone else.

comments: author: Robert Turner
body: Final note from support ticket - technical support person expected the documentation will be updated to reflect what I shared above.


Tags: jira-cloud