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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 do I modify variables in a build Edited

I'm trying use the variable BITBUCKET_BRANCH to define a filename, but the slash is causing us issues. Here's a sample YAML

- step:
name: Build javascript
image: node:12.16.3
- node
- apt-get update && apt-get install --yes zip
- npm install
- npx ng build
- zip -r ${BITBUCKET_BRANCH}.zip dist
- pipe: atlassian/bitbucket-upload-file:0.1.4


How can I modify the BITBUCKET_BRANCH variable to remove non-alphanumeric characters? For example changing from: feature/bitbucket-ci --> featurebitbucketci.

2 answers

0 votes

Hi @Jacob Craig ,

Thank you for your question!

You could create a new variable:

- ARTIFACT_FILENAME=$(echo $BITBUCKET_BRANCH | sed "s/[^a-zA-Z0-9]//g")
- zip -r ${ARTIFACT_FILENAME}.zip dist

That part was easy enough to do, the question was how to send that into the pipe.


I thought those were unfurled at the beginning of the run.

I did not test this on Bitbucket but I can imagine it works this way:

  • Define a new variable that contains the filename in the form you prefer
  • Use it in your step-script (e.g. for creating the zip)
  • Export it so that mapping to the variable table of the Pipe works (?)

Example (tested to work with the node:12.16.3 image):

- PACKAGE_FILE="${BITBUCKET_BRANCH//\//-}.zip" # replace all slashes with dashes
  - zip -r ${PACKAGE_FILE} dist
- pipe: atlassian/bitbucket-upload-file:0.1.4


It might already work like this. Fine. Here is some more context of why I suggest this:

It is my understanding that the variables property of a pipe needs to contain strings. These are passed to the docker run command that runs the pipe image as --env NAME=value command line options and arguments.

This command runs in the same shell script as the other script lines. Therefore technically the export should not be necessary. Additionally it should not be necessary to use the plain string $PACKAGE_FILE for the FILENAME: property. However from your report I'm not entirely sure if this is stable and as written I didn't test this on Bitbucket (and the local Bitbucket Pipeline runner I'm using does not have full pipe support [yet], so local testing is limited to some degree).

Therefore the extra script line to export the $PACKAGE_FILE variable and overall to create an extra variable so that the pipe.variables table has it in a simple manner (just $PACKAGE_FILE, just the variable name prefixed with the dollar sign "$").

Suggest an answer

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

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

641 views 10 16
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