无法使用 Bitbucket 管道在 google 云应用引擎上部署

Cant deploy on google cloud app engine using Bitbucket pipeline

我在 app engine 中部署了一个 java 网络应用程序,源代码在 Bitbucketmaster branch

我听说 bitbucket pipelines 我发现它作为一种快速的自动部署方式很有帮助

我的 master 分支有 4 个项目列表:

 master --
      |- project1
      |- project2
      |- project3
      |- project4 
      |- bitbucket-pipelines.yml

我完全按照 link 中的内容提供管道功能:

https://confluence.atlassian.com/bitbucket/deploy-to-google-cloud-900820342.html

这是我的 bitbucket-pipelines.yml 内容,它直接位于我的 master 分支下

image: maven:3.3.9

pipelines:
  branches: 
    master:
     - step:
        caches:
          - maven
        script: 

        # 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 | base64 --decode --ignore-garbage > ./gcloud-api-key.json

          - gcloud config set project $CLOUDSDK_CORE_PROJECT

          - gcloud components install app-engine-java
          - gcloud auth activate-service-account --key-file client-secret.json
          - cd project1 
          - mvn clean install package
          - 'mvn appengine:update' 

CLOUDSDK_CORE_PROJECT : 是一个包含项目 ID 的管道变量 GOOGLE_CLIENT_SECRET :是一个管道变量,包含 base64 编码的服务帐户 json 文件,如附件 link

中所述

这是我在 pom.xml

中的应用引擎插件
<plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.target.version}</version>
            <configuration>
            <enableJarClasses>false</enableJarClasses>
               <oauth2>false</oauth2>
        </configuration>
        </plugin>        

在我 运行 我的管道之后,我在执行 "mvn appengine:update"

行时遇到了这个错误
lease visit https://developers.google.com/appengine/downloads for the latest SDK.
********************************************************
The following URL can be used to authenticate:
  https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&client_id=550516889912.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/appengine.admin%20https://www.googleapis.com/auth/cloud-platform
Attempting to open it in your browser now.
Unable to open browser. Please open the URL above and copy the resulting code.
Please enter code: Encountered a problem: No line found
Please see the logs [/tmp/appcfg3177766291803906341.log] for further information.

然后管道结果失败,我找了2天这个错误没有希望,我希望能来帮助我

提前致谢!

我修复了它,事实证明 bitbucket 中的文档具有误导性,这是正确的管道脚本,您只需将这 3 行代码放在之后立即构建并部署到 google 云:

       - mvn install package
       - echo $GOOGLE_CLIENT_SECRET > /tmp/client-secret.json    
       - mvn appengine:update -Dappengine.additionalParams="--service_account_json_key_file=/tmp/client-secret.json"

$GOOGLE_CLIENT_SECRET 是一个具有 App Engine 默认服务帐户 json 服务帐户的环境变量,或者您可以创建一个具有 project editor 特权

的新帐户

它帮助我通过了身份验证错误,但现在我在日志中看到 403。令人惊讶的是,该版本仍被推送到 app-engine 但流量为 0%。

Beginning interaction for module default...
0% Created staging directory at: '/var/folders/ny/z92xw4ps0j71v43mnvjzjyd80000gn/T/appcfg16663468200304338426.tmp'
5% Scanning for jsp files.
8% Generated git repository information file.
20% Scanning files on local disk.
25% Initiating update.
28% Cloning 34 application files.
40% Uploading 3 files.
52% Uploaded 1 files.
61% Uploaded 2 files.
68% Uploaded 3 files.
73% Sending batch containing 3 file(s) totaling 41KB.
77% Initializing precompilation...
90% Deploying new version.
95% Closing update: new version is ready to start serving.
98% Uploading index definitions.
Feb. 19, 2018 1:21:24 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #0
Feb. 19, 2018 1:21:25 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #1
Feb. 19, 2018 1:21:25 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #2
Feb. 19, 2018 1:21:25 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #3

Error Details:
2018-02-19 01:20:57.438:INFO::main: Logging initialized @378ms
2018-02-19 01:20:57.575:INFO:oejs.Server:main: jetty-9.3.18.v20170406
2018-02-19 01:20:58.829:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=711ms
2018-02-19 01:20:58.843:INFO:oejq.QuickStartDescriptorGenerator:main: Quickstart generating
2018-02-19 01:20:58.859:INFO:oejsh.ContextHandler:main: Started o.e.j.q.QuickStartWebApp@2aceadd4{/,file:///private/var/folders/ny/z92xw4ps0j71v43mnvjzjyd80000gn/T/appcfg16663468200304338426.tmp/,AVAILABLE}
2018-02-19 01:20:58.861:INFO:oejs.Server:main: Started @1808ms
2018-02-19 01:20:58.863:INFO:oejsh.ContextHandler:main: Stopped o.e.j.q.QuickStartWebApp@2aceadd4{/,file:///private/var/folders/ny/z92xw4ps0j71v43mnvjzjyd80000gn/T/appcfg16663468200304338426.tmp/,UNAVAILABLE}