使用Bitbucket管道部署GCloud App

时间:2018-02-05 06:09:09

标签: google-cloud-platform bitbucket bitbucket-pipelines

我想在生产环境中使用bitbucket管道部署我的应用程序。

我按照https://cloud.google.com/solutions/continuous-delivery-bitbucket-app-engine中的说明进行操作,但这是在暂存环境中部署我的应用程序。

我的管道文件是

image: python:2.7

pipelines:
  branches:
    master:
      - step:
          script: # Modify the commands below to build your repository.
            # Downloading the Google Cloud SDK
            - curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
            - tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/
            - /tmp/google-cloud-sdk/install.sh -q
            - source /tmp/google-cloud-sdk/path.bash.inc
            # Authenticating with the service account key file
            - echo ${GOOGLE_CLIENT_SECRET} > client-secret.json
            - gcloud auth activate-service-account --key-file client-secret.json
            # Linking to the Google Cloud project
            - gcloud config set project $CLOUDSDK_CORE_PROJECT
            - gcloud -q app deploy app.yaml

这显示以下错误

You are about to deploy the following services:
 - my-app/default/232326565655 (from [/opt/atlassian/pipelines/agent/build/app.yaml])
     Deploying to URL: [https://my-app.appspot.com]
Beginning deployment of service [default]...
Some files were skipped. Pass `--verbosity=info` to see which ones.
You may also view the gcloud log file, found at
[/root/.config/gcloud/logs/2018.02.05/05.25.49.374053.log].
ERROR: gcloud crashed (UploadError): Error uploading files: HttpError accessing <https://www.googleapis.com/storage/v1/b/staging.my-app.appspot.com/o?alt=json&maxResults=1000>: response: <{'status': '403', 'content-length': '410', 'expires': 'Mon, 05 Feb 2018 05:25:52 GMT', 'vary': 'Origin, X-Origin', 'server': 'UploadServer', 'x-guploader-uploadid': 'UPLOADER_ID', 'cache-control': 'private, max-age=0', 'date': 'Mon, 05 Feb 2018 05:25:52 GMT', 'alt-svc': 'hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"', 'content-type': 'application/json; charset=UTF-8'}>, content <{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "bitbucket-authorization@my-app.iam.gserviceaccount.com does not have storage.objects.list access to staging.my-app.appspot.com."
   }
  ],
  "code": 403,
  "message": "bitbucket-authorization@my-app.iam.gserviceaccount.com does not have storage.objects.list access to staging.my-app.appspot.com."
 }
}

1 个答案:

答案 0 :(得分:0)

遵循相同的tutorial并根据您提供的错误,您使用的服务帐户&#34;&#34; bitbucket-authorization@my-app.iam.gserviceaccount.com"没有权限访问暂存存储桶。

确保App Engine和gt; App Engine Admin&amp;存储&gt;存储对象管理员角色从Cloud Console提供给此服务帐户。

在为该教程使用新项目时,我注意到的最后一件事是我必须手动启用Google App Engine Admin API

编辑: 您可以在bitbucket使用的脚本中使用标记--bucket=gs://BUCKETNAME来部署:

即 - &gt; gcloud app deploy --bucket =&#34; gs:// BUCKETNAME&#34;

相关问题