Docker 推送失败到 Dockerhub - 标签不存在

问题描述 投票:0回答:1

我的 bitbucket 管道失败,标签不存在,指的是 dockerhub 图像推送

这是 bitbucket-pipelines.yaml 配置

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}

还有 build-docker.sh

#!/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;
docker bitbucket cicd docker-registry bitbucket-pipelines
1个回答
0
投票

这是因为您没有为环境变量提供任何值 -

ENVIRONMENT


pipelines:
  default:
    - step:
        name: Build Docker Image
        caches:
          - docker
        script:
          - echo 'Building Docker image but skipping Deploy for feature branch'
          - sh ./build-docker.sh <Provide_Some_Value>

您需要根据您的 .sh 文件在此处添加一些值 -

sh ./build-docker.sh <Provide_Some_Value>

根据您的 bash 脚本,它期望第一个标志有一些值

#!/usr/bin/env bash
ENVIRONMENT=${1}

例如:-

sh ./build-docker.sh Prod

此后,您将不会收到错误。

© www.soinside.com 2019 - 2024. All rights reserved.