I am trying to build multiple Docker images with less code duplication.
Every step is doing:
- docker build -t ${ECR_ENDPOINT}/${IMAGE_NAME}:${BITBUCKET_BRANCH} .
- docker push ${ECR_ENDPOINT}/${IMAGE_NAME}:${BITBUCKET_BRANCH}
But it is not possible to set IMAGE_NAME variable per step.
Maybe if BITBUCKET_STEP_NAME is available, I can put the docker image name there ?
https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html
Right now I am hacking with:
- if [[ $BITBUCKET_PARALLEL_STEP -eq 0 ]];then IMAGE_NAME="image";fi
- if [[ $BITBUCKET_PARALLEL_STEP -eq 1 ]];then IMAGE_NAME="another-image";fi
- if [[ $BITBUCKET_PARALLEL_STEP -eq 2 ]];then IMAGE_NAME="image-foo";fi
- aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${ECR_ENDPOINT}/${IMAGE_NAME}
- cd ${IMAGE_NAME}
- docker build -t ${ECR_ENDPOINT}/${IMAGE_NAME}:${BITBUCKET_BRANCH} .
- docker push ${ECR_ENDPOINT}/${IMAGE_NAME}:${BITBUCKET_BRANCH}