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

How to get name of the step of the pipeline and use that name in Email notify subject

Abinaya Abi
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 20, 2024

I am using Cypress and Bitbucket for CI/CD. I have scheduled the run in bitbucket pipeline. I use the email notify feature in after script to get the test result via mail. it is difficult for me to understand which module failed. I have added bitbucket build number, step uuid. But, I want to include the name that I have added in the script.

I want the {BITBUCKET_STEP_NAME} to have the name of the step that is "Module 1". But, it was not working.

 

step: <<: default-step

name: Module 1

after-script: 

pipe: atlassian/email-notify:0.13.1

variables:

USERNAME: "xxxx@gmail.com"

PASSWORD: "......"

FROM: "xxxx@gmail.com"

TO: "yyyy@gmail.com"

HOST: "smtp.gmail.com"

PORT: 587

DEBUG: "true"

SUBJECT: "${BITBUCKET_STEP_NAME} [STAGING] BUILD# ${BITBUCKET_BUILD_NUMBER} ${STATUS}: ${BITBUCKET_STEP_NAME} Notification for ${BITBUCKET_BRANCH}."

BODY_PLAIN: "The artifacts can be downloaded from the following URL: $ARTIFACTS_URL"

 

${BITBUCKET_STEP_NAME}

 

${BITBUCKET_STEP_NAME}

 

${BITBUCKET_STEP_NAME}

1 answer

1 vote
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 22, 2024

Hi Abinaya,

BITBUCKET_STEP_NAME is not a default variable that can be referred to, hence why it's not returning the expected result. We have a feature request raised with our developers to include this so that it can be referenced in builds:

In the description of the above feature request, there is a workaround for grabbing the step name within the build script by using our REST API and authenticating with App Password - for example:

 BITBUCKET_STEP_NAME=$(curl --request GET --url "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_FULL_NAME}/pipelines/%7B${BITBUCKET_PIPELINE_UUID}%7D/steps/%7B${BITBUCKET_STEP_UUID}%7D?fields=name" -u $BITBUCKET_USERNAME:$BITBUCKET_APP_PASSWORD | jq -r '.name')

I hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

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

Atlassian Community Events