Gitlab Cloud 运行部署成功但作业失败

MIk*_*ode 4 gitlab google-cloud-platform

我的 CI/CD 管道有问题,它已成功部署到 GCP 云运行,但在 Gitlab 仪表板上状态为失败。

我尝试将图像替换为其他一些 docker 图像,但也失败了。

 # File: .gitlab-ci.yml
image: google/cloud-sdk:alpine
deploy_int:
  stage: deploy
  environment: integration
  only:
  - integration    # This pipeline stage will run on this branch alone
  script:
    - echo $GCP_SERVICE_KEY > gcloud-service-key.json # Google Cloud service accounts
    - gcloud auth activate-service-account --key-file gcloud-service-key.json
    - gcloud config set project $GCP_PROJECT_ID
    - gcloud builds submit . --config=cloudbuild_int.yaml




# File: cloudbuild_int.yaml
steps:
    # build the container image
  - name: 'gcr.io/cloud-builders/docker'
    args: [ 'build','--build-arg','APP_ENV=int' , '-t', 'gcr.io/$PROJECT_ID/tpdropd-int-front', '.' ]
    # push the container image
  - name: 'gcr.io/cloud-builders/docker'
    args: [ 'push', 'gcr.io/$PROJECT_ID/tpdropd-int-front']
    # deploy to Cloud Run
  - name: "gcr.io/cloud-builders/gcloud"
    args: ['run', 'deploy', 'tpd-front', '--image', 'gcr.io/$PROJECT_ID/tpdropd-int-front', '--region', 'us-central1', '--platform', 'managed', '--allow-unauthenticated']
Run Code Online (Sandbox Code Playgroud)

gitlab构建输出:

ERROR: (gcloud.builds.submit) 
The build is running, and logs are being written to the default logs bucket.
This tool can only stream logs if you are Viewer/Owner of the project and, if applicable, allowed by your VPC-SC security policy.
The default logs bucket is always outside any VPC-SC security perimeter.
If you want your logs saved inside your VPC-SC perimeter, use your own bucket.
See https://cloud.google.com/build/docs/securing-builds/store-manage-build-logs.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
Run Code Online (Sandbox Code Playgroud)

小智 7

我通过使用以下方法修复它:

options:
  logging: CLOUD_LOGGING_ONLY
Run Code Online (Sandbox Code Playgroud)

在cloudbuild.yaml中

  • 通过添加更多有关代码的作用以及它如何帮助操作员的信息,可以改进您的答案。 (6认同)