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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,053
Community Members
 
Community Events
176
Community Groups

Environment variables from my project settings not properly working in my pipelines

I am trying to use some environment variables in my bitbucket pipeline scripts and it looks like the variables are not being passed, for example:

- VERSION=${BITBUCKET_TAG:-${BITBUCKET_BRANCH//\//_}-latest}
- IMAGE_NAME="${NEXUS_DOCKER_PRIVATE_REGISTRY_URL}/baseline-service:${VERSION}"
- docker build . -t $IMAGE_NAME --pull --no-cache --label 'GIT_COMMIT_HASH=$BITBUCKET_COMMIT'

In that case, NEXUS_DOCKER_PRIVATE_REGISTRY_URL is my environment variable, but it's not being translated properly:

+ docker build . -t $IMAGE_NAME --pull --no-cache --label 'GIT_COMMIT_HASH=$BITBUCKET_COMMIT'
invalid argument "$NEXUS_DOCKER_PRIVATE_REGISTRY_URL/my-service:feature_pipeline-latest" for "-t, --tag" flag: invalid reference format

1 answer

1 accepted

0 votes
Answer accepted

Hello @kalib ,

From the error message seems like the IMAGE_NAME variable was not populated correctly. Checking the syntax you have used in IMAGE_NAME, it seems to be correct, and testing on my repository it was correctly presenting the value.

 

Could you please confirm if the NEXUS_DOCKER_PRIVATE_REGISTRY_URL has not any typo when you created it in your repository settings/workspace settings ?

One thing you can also do for troubleshooting is to print the variables using echo after you have created them and see if the value is correct, like below :

 

- VERSION=${BITBUCKET_TAG:-${BITBUCKET_BRANCH//\//_}-latest}
- echo $VERSION - IMAGE_NAME="${NEXUS_DOCKER_PRIVATE_REGISTRY_URL}/baseline-service:${VERSION}"
- echo $IMAGE_NAME
- echo $NEXUS_DOCKER_PRIVATE_REGISTRY_URL

Would you please try the above and let us know the output ?

Thank you, @kalib .

Kind regards,

Patrik S

Thanks, this method for validation worked for me as well. Thanks, it will make it way easier for troubleshooting.

Like Patrik S likes this
Patrik S Atlassian Team Apr 20, 2022

Hey @kalib ,

Awesome! It's indeed way easier to investigate when printing the variable value with echo. Do let us know in case you have any other questions.

Kind regards,

Patrik S

Like kalib likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events