You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.