Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I retrieve the ticket number from a pipeline ?

federico October 23, 2022

Hello,

I would like to create the following flow.

user commit and PR a feature, then on the pipeline

=> Lint/Test
=> Build a preview
=> Deploy a preview
=> Automatically comment on ticket with preview link and move to QA.

I am unsure how to achieve this last step.
I am using Bibucket Cloud and Jira and probably would use Smart Commit .

The question is, how can I retrieve the ticket number from the pipeline ? I know there is some variables, but none seems related to the Jira Ticket. I would like to be able to retrieve this from the `bitbucket-pipelines.yml` the same way the PR page can know the associated tickets.

Is it possible ? 

Thank you 

1 answer

1 vote
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 25, 2022

Hi @federico,

Thank you for reaching out to the community.

For the last step in your workflow, I don't think there's a default variable in Pipelines that fetches a Jira issue link. - Bitbucket Pipelines variables

As a workaround, since there is the default variable BITBUCKET_COMMIT in Pipelines, you can run a Git command to show extract the commit's message.
From that commit message, you can then parse the result to get the Jira issue key given the commit message has an issue key.

# To get the commit's message
- export commit_message=$(git show -s --format=%B $BITBUCKET_COMMIT)
# Parse the variable *commit_message* to get the Jira issue key

Hope it helps.

Regards,
Mark C

Suggest an answer

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

Atlassian Community Events