0

我正在尝试通过 GitLab ci 管道将 Docker 映像推送到 Google Cloud Registry。

图像构建,但是当它推送到注册表时,我收到以下错误。

拒绝:项目“xxx-dev01-xxxxxx”的令牌交换失败。违反组织政策:“eu”违反了约束“constraints/gcp.resourceLocations”

.gitlab.yaml

deploy:dev:
  allow_failure: true
  extends:
    - .prod
  stage: Deploy
  image: google/cloud-sdk
  services:
    - docker:dind
  variables:
    IMAGE_TAG: "eu.gcr.io/$PROJECT_ID/testapp"
  before_script:
    - echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
    - gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
    - gcloud config set project $DEV_PROJECT_ID
    - gcloud auth configure-docker
    - gcloud services enable containerregistry.googleapis.com
    - docker login -u _json_key --password-stdin https://eu.gcr.io < ${HOME}/gcloud-service-key.json
  script:
    - docker build . -t "$IMAGE_TAG" 
    - docker push $IMAGE_TAG:latest
  when: manual  
4

1 回答 1

2

它似乎违反了您的一项组织政策,即“资源位置”之一。

根据文档,您的公司似乎阻止您将数据存储到此位置(区域)。

https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations

您可能想尝试eu.gcr.io使用此列表中的另一个进行更改。

https://cloud.google.com/container-registry/docs/pushing-and-pulling#add-registry

于 2021-03-27T08:00:33.340 回答