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
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.