My bitbucket pipelines are failing with tag does not exist referring to dockerhub image push
this is the bitbucket-pipelines.yaml config
image: node:8
pipelines:
default:
- step:
name: Build Docker Image
caches:
- docker
script:
- echo 'Building Docker image but skipping Deploy for feature branch'
- sh ./build-docker.sh
branches:
development:
- step:
name: Deploy to Development
caches:
- docker
deployment: test
script:
- export DOCKER_BUILDKIT=0
- export LABEL=$(TZ=':America/Phoenix' date +%Y%m%d%H%M)
- sh ./deploy.sh development ${LABEL}
and the build-docker.sh being
#!/usr/bin/env bash
ENVIRONMENT=${1}
BITBUCKET_COMMIT=${BITBUCKET_COMMIT}
BITBUCKET_BRANCH="${BITBUCKET_BRANCH:-${ENVIRONMENT}}"
# Build Docker image
docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker build -t intraedge/truyo-php:${ENVIRONMENT}-${BITBUCKET_COMMIT} -t intraedge/truyo-php:${ENVIRONMENT} --build-arg env=${ENVIRONMENT} .
if [[ $BITBUCKET_BRANCH == 'oci-poc' ]] || [[ $BITBUCKET_BRANCH == 'development' ]] || [[ $BITBUCKET_BRANCH == 'staging' ]] || [[ $BITBUCKET_BRANCH == 'qa' ]] || [[ $BITBUCKET_BRANCH == 'master' ]]; then
# and push to repository
docker push intraedge/truyo-php:${ENVIRONMENT}
docker push intraedge/truyo-php:${ENVIRONMENT}-${BITBUCKET_COMMIT}
fi;
Here is the deploy.sh
#!/usr/bin/env bash
ENV=${1}
COMMIT=${BITBUCKET_COMMIT}-${2}
# Build Docker image and push to repository
docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD}
docker build -t intraedge/truyo-php:${ENV}-${COMMIT} -t intraedge/truyo-php:${ENV} --build-arg env=${ENV} .
docker push intraedge/truyo-php:${ENV}
docker push intraedge/truyo-php:${ENV}-${COMMIT}
This is because you are not providing any value to the Environment Variable -
ENVIRONMENTYou need to add some value over here as per your .sh file -
sh ./build-docker.sh <Provide_Some_Value>.As per your bash script, it is expecting some value at the first flag
For Example :-
sh ./build-docker.sh ProdAfter this, you won't receive the error.