Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to pass jira issue ids to bamboo build plan variable?

I'm looking for a way to integrate linked jira issues into build workflow.
For every bamboo build I can browse linked jira issues in GUI. How can I access this information in build scripts?

I also tried creating release from jira, manually linking issues to release and then triggering build from jira. Unfortunately still I don't see how to gather related ticket keys.

2 answers

We had to create a script in the end as a workaround. We use the ${bamboo.planRepository.revision} variable to give us the related Bitbucket commit. All of our branches in bitbucket contain the linked JIRA ticket number within the commit details returned from the Bitbucket API. Our solution connects to the Bitbucket API and uses the above build variable to return all of the commit details, once returned we grep the response to identify the JIRA ticket number linked with the commit. You'll have to update the <JIRA_ticket_prefix> below to use your project's ticket prefix, in our case this is followed by 4 numbers at the moment, but if you have more you'll have to update the {4} below too.


Once we have the JIRA ticket number returned, we then save it to a file located: /var/lib/bamboo-home/artifacts/variable_injection but again, you can change this to whatever you wish.




# Sign in to Bitbucket and get a token
ACCESS_TOKEN=$(curl -s -X POST -u "$BITBUCKET_CLIENT_ID:$BITBUCKET_CLIENT_SECRET" -d grant_type=password -d username=$BITBUCKET_USERNAME -d password=$BITBUCKET_PASSWORD | jq '.access_token')

# Get the JIRA ticket number from the commit
TICKET=$(curl -s<company_name>/<repo>/commit/$COMMIT?access_token=$ACCESS_TOKEN | jq '.rendered.message.raw' | grep -P '(<JIRA_ticket_prefix>.[0-9]{4})' -o | uniq)

echo "** Found JIRA ticket: $TICKET from commit: $COMMIT"

# Write the feature tag to a file for Bamboo
echo "jiraticket=$TICKET" > "$OUTPUT_DIRECTORY/variable_injection"


Once all of this has finished, you should have a JIRA ticket number stored in a file /var/lib/bamboo-home/artifacts/variable_injection 

Next, you can use the bamboo Inject Variable task to read the file ../../../artifacts/variable_injection which contains your JIRA ticket number and creates a variable of ${bamboo.inject.jiraticket} to then be used elsewhere in your build.


It seems pretty long-winded, but it's the only thing we could think of for the time being as a workaround until Bamboo creates its own JIRA ticket variable.


Hope this helps people,


Hey Dan,

Thanks for sharing.


Answers my query also.




0 votes
Jeyanthan I Atlassian Team Feb 06, 2020

Hey @Konrad Gancarz ,

If I understand correctly, you wanted to refer the Jira isssue ID in Bamboo builds. I was going to suggest one of the default Bamboo variables for Jira. I then realised there is no variable to collect Issue ID that triggered the build.

Available JIRA variables (as of Bamboo 6.10.4) are as follows:

  • ${bamboo.jira.baseUrl} - The URL of your JIRA application server.
  • ${bamboo.jira.projectKey} - The key of the triggering JIRA application project.
  • ${bamboo.jira.projectName} - The name of the triggering JIRA application project.
  • ${bamboo.jira.username} - The username of the user who triggered the release build.
  • ${bamboo.jira.version} - The release version of the triggering Jira application project.

I have therefore created a feature request on your behalf. Please upvote and comment.

As a workaround, I propose

  1. Create a script Task within the plan.
  2. In the script, make a REST call to Jira to fetch the corresponding Issue ID.

References to REST documentation: 

Hope that helps!


Hi Jey,

How would we make a REST call to Jira to fetch the corresponding issue ID when the details aren't stored in Bamboo? Looking at the Jira REST API docs, we'd need to provide the issue ID in the call?

Please could you give an example?



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo Data Center 8.1 is now available

G’day Bamboo customers, Bamboo DC 8.1 is now available with it the following features and programs: SAML 2.0, OpenID Connect, and Crowd SSO In order to help admins with a simplified user manage...

180 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you