Create
cancel
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

Passing Variables to a script in pipelines

I have set up some repository variables which I can call in my bitbucket-pipelines.yml file using $API_KEY

But What I cannot figure out is how to pass those variables into one of the scripts I have running in the step my yml looks something like this

clone:
depth: full

options:
max-time: 20

pipelines:
branches:
develop:
- step:
name: Create config and deploy
image: node:10.15.3
script:
- npm install
- npm test
- bin/generate-config.js
variables:
API_KEY: $DEV_API_KEY
- bin/deploy.sh

 in github i know you can have env: and put variables in there but I'm not sure how to achieve this with bb pipelines.

And within my .js file I'm not sure how I can then call these passed variables

1 answer

1 accepted

1 vote
Answer accepted

i fixed this just doing the following 

pipelines:
branches:
develop:
- step:
name: Create config and deploy
image: node:10.15.3
script:
- npm install
- npm test
- bin/generate-config.js $DEV_API_KEY
- bin/deploy.sh

 Then within my .js file just using 

const apiKey = process.argv[2];

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,725 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