Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Erik Spears
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 17, 2021

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):  https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/

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
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2021

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,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events