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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Passed variables to npm script are empty

I have the following in the bitbucket-pipeline.yml:

script
:
- npm install
- API_URL=$API_URL npm run build

and unsecured deployment variable API_URL that has value https://example.com

console.log(process.env.API_URL)  show nothing in the pipeline log when build is started.

When using hardcoded url everything works as expected:

script
:
- npm install
- API_URL=https://example.com npm run build

Not sure what am I doing wrong?

Any help is much appreciated.

2 answers

1 accepted

0 votes
Answer accepted

Thank you @Syahrul

It was a missunderstaning on my part. I was expecting that deployment variables are accessible acros all steps.

I solved it by creating repository level variables, since those can be used in all steps.

Thanks again, cheers!
0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jan 09, 2022

Hi @senad87 

Welcome to the community!

Could you try to add echo on the variable before the steps that you use to call it to verify that pipeline is correctly showing the variable as the following example:

        script:
             - echo "$API_URL"

 This should create an echo output of the variable in the pipeline build where you can use to verify if the variable is correctly showing the output you configure as below example:

Screenshot 2022-01-10 at 1.18.37 PM.png

If it's not showing any echo output or the output is different from what you expected then the variable may be using a secure variable or you have a conflict variable that you may have configured in the deployment variable or the workspace variable.

I hope this helps.

Cheers,
Syahrul

Thank you Syahrul! 

It was a missunderstaning on my part. I was expecting that deployment variables are accessible acros all steps.

I solved it by creating repository level variables, since those can be used in all steps.

Thanks again, cheers!

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events