Bitbucket管道部署到gCloud AppEngine的原因[13]发生内部错误

时间:2018-09-15 19:04:04

标签: node.js google-app-engine bitbucket-pipelines

我正在尝试在我的项目中使用位桶管道。我使用Nodejs。

当我从Mac或Windows手动运行gcloud app deploy时-它运行正常,部署成功完成。但是从bitbucket管道中失败,并显示错误响应:[13]发生内部错误。

这是我通过运行gcloud app deploy --verbosity=debug获得的堆栈跟踪:

Updating service [default]...
.DEBUG: Operation [apps/my-project/operations/a68a837e-edcf-4987-83db-d9b47f4309ae] not complete. Waiting to retry.
.......DEBUG: Operation [apps/my-project/operations/a68a837e-edcf-4987-83db-d9b47f4309ae] complete. Result: {
    "metadata": {
        "target": "apps/my-project/services/default/versions/20180915t180908", 
        "method": "google.appengine.v1.Versions.CreateVersion", 
        "user": "bitbucket-works@my-project.iam.gserviceaccount.com", 
        "insertTime": "2018-09-15T18:09:46.693Z", 
        "endTime": "2018-09-15T18:09:49.655Z", 
        "@type": "type.googleapis.com/google.appengine.v1.OperationMetadataV1"
    }, 
    "done": true, 
    "name": "apps/my-project/operations/a68a837e-edcf-4987-83db-d9b47f4309ae", 
    "error": {
        "message": "An internal error occurred.", 
        "code": 13
    }
}
failed.

DEBUG: (gcloud.app.deploy) Error Response: [13] An internal error occurred.
Traceback (most recent call last):
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 839, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 770, in Run
    resources = command_instance.Run(args)
  File "/tmp/google-cloud-sdk/lib/surface/app/deploy.py", line 90, in Run
    parallel_build=False)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 625, in RunDeploy
    flex_image_build_option=flex_image_build_option)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 431, in Deploy
    extra_config_settings)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 207, in DeployService
    poller=done_poller)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 315, in WaitForOperation
    sleep_ms=retry_interval)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 254, in WaitFor
    sleep_ms, _StatusUpdate)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 316, in PollUntilDone
    sleep_ms=sleep_ms)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 229, in RetryOnResult
    if not should_retry(result, state):
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 310, in _IsNotDone
    return not poller.IsDone(operation)
  File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 184, in IsDone
    encoding.MessageToPyValue(operation.error)))
OperationError: Error Response: [13] An internal error occurred.
ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred.

我的bitbucket-pipelines.yml:

pipelines:
  default:
    - step:
        name: Test and deployment
        image: node:8.9
        script: # Modify the commands below to build your repository.
          - npm install
          - npm test
          - npm build
          # 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-216.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
          # Setup
          - echo $GCLOUD_CLIENT_SECRET > client-secret.json
          - gcloud auth activate-service-account --key-file client-secret.json
          - gcloud config set project $GCLOUD_PROJECT
          - gcloud -q app deploy --verbosity=debug

我的.gcloudignore:

.gcloudignore
.git
.gitignore

# Node.js dependencies:
node_modules/
design/

我在StackOverflow和Google上找到了一些解决方案,但没有任何效果。我尝试了不同版本的Google Cloud SDK-但结果是相同的。 感谢您的任何提前帮助。

1 个答案:

答案 0 :(得分:1)

最后,我已经解决了。

TL; DR:

在IAM和管理页面上为您的Bitbucket成员添加 Cloud Build Editor 角色。


我已经将GCloud版本更新到了218,并且开始显示有关该错误的更多信息(不仅仅是发生内部错误):

OperationError: Error Response: [13] Permission to create cloud build is denied. 'Cloud Build Editor' role is required for the deployment: https://cloud.google.com/cloud-build/docs/securing-builds/configure-access-control#permissions.

问题是GCloud上的bitbucket成员缺少权限。似乎这是最近增加的一项要求,因为没有任何手册可以提供有关的信息。

要解决此问题,您应该在IAM和管理页面上为您的bitbucket成员添加 Cloud Build Editor 角色。

希望有帮助。