Bitbucket pipelines deploy to gCloud AppEngine cau

2019-07-18 11:41发布

I'm trying to use bitbucket pipelines with my project. I use Nodejs.

When I'm running gcloud app deploy manually from Mac or Windows - it works fine, deploy successfully finishes. But from bitbucket pipelines it fails with Error Response: [13] An internal error occurred.

Here is the stack trace which I've got by running 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.

My 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

My .gcloudignore:

.gcloudignore
.git
.gitignore

# Node.js dependencies:
node_modules/
design/

I found some solution on StackOverflow and Google, but nothing works. I've tried different versions of Google Cloud SDK - but the result is the same. Thanks for any help in advance.

1条回答
Explosion°爆炸
2楼-- · 2019-07-18 12:08

Finally, I've solved it.

TL;DR:

Add Cloud Build Editor role for your bitbucket member on IAM & admin page.


I've updated GCloud version up to 218 and it started to show more information about the error (not just internal error occurred):

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.

The problem is lack of permissions for bitbucket member on GCloud. Seems like it's a recently added requirement, 'cause no one manual has information about.

To solve the issue you should add Cloud Build Editor role for your bitbucket member on IAM & admin page.

Hope it helps.

查看更多
登录 后发表回答