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

Can I capture a Bitbucket build number in a Jira issue?

We are using the Cloud products, and while I keep finding server product answers to this online, they don't immediately seem workable in the Cloud versions.

So, my use case / ask is this:  After a PR is merged and build process completes (or even if it doesn't), I'd like to get that Bitbucket build number displayed (and linked, ideally) in the corresponding Jira ticket.

I know the BB build number is available in some sense from this page (and others):

See the second row of the table:  BITBUCKET_BUILD_NUMBER

However, the custom field options I'm seeing in the Cloud version of Jira aren't obvious candidates for pulling this in, but I'm open to all options or ideas!  :D

Thanks for any suggestions!

1 answer

0 votes

Hi Erik,

The BITBUCKET_BUILD_NUMBER is a Pipelines variable and it is accessible only to the build while it is running. It cannot be used outside of the build.

We have an integration for Bitbucket Pipelines and Jira Software that allows you to see build information on a Jira issue, however, it requires that you put the issue key in the branch name:

I am quoting the example from the documentation, if you have a branch named 'feature/ST-1-build-mk2-boosters', then build information would appear in the Jira issue ST-1 every time your pipeline runs against a commit within that branch. I'm not sure if this is something that would suit your needs?

Another idea would be to have a custom field in Jira, and then update its value via an API call in the after-script of the Pipelines build. One issue here would be how to get the Jira issue key during the build, in order to update the Jira issue.

I was wondering if you could give us some more details on your use case, so we can see if there's a way to achieve what you like:

1. You mention "After a PR is merged and build process completes": how are these builds defined in the yml file? Is it builds that run automatically on a specific branch, e.g. master or develop, and they get triggered when you merge a PR to that branch? Or are they custom builds?

2. Do you use the source branch of each PR for only one Jira issue?

3. Do you have Jira issue keys references in the commits of the source branch of the PR? In the title of the PR? Or in the merge commit? And, related to the previous question, do you only reference one Jira issue in each source branch?

Kind regards,

Suggest an answer

Log in or Sign up to answer
Site Admin
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

111 views 2 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