【问题标题】:GCloud permission error when deploying to Google app engine flexible灵活部署到 Google 应用引擎时出现 GCloud 权限错误
【发布时间】:2018-02-18 07:17:41
【问题描述】:

我正在尝试使用 Maven 通过 Jenkins 将我的 Spring Boot 应用程序部署到应用程序引擎。在 maven 构建包之后,我在 Build 步骤的执行 shell 中使用“mvn install appengine: deploy”。但是,我在构建时收到以下错误,

GCLOUD: ERROR: (gcloud.app.deploy) Permissions error fetching application [apps/microservice-qa]. Please make sure you are using the correct project ID and that you have permission to view applications on the project.

详细的错误跟踪:

[INFO] Detected App Engine flexible environment application.
Sep 12, 2017 7:54:14 AM com.google.cloud.tools.appengine.cloudsdk.CloudSdk logCommand
INFO: submitting command: /usr/lib/google-cloud-sdk/bin/gcloud app deploy
[INFO] GCLOUD: Services to deploy:
[INFO] GCLOUD:
[INFO] GCLOUD: descriptor:      [/opt/bitnami/apps/jenkins/jenkins_home/workspace/demo-test/target/appengine-staging/app.yaml]
[INFO] GCLOUD: source:          [/opt/bitnami/apps/jenkins/jenkins_home/workspace/demo-test/target/appengine-staging]
[INFO] GCLOUD: target project:  [xxxx]
[INFO] GCLOUD: target service:  [xxxxx]
[INFO] GCLOUD: target version:  [20170912t075415]
[INFO] GCLOUD: target url:      [https://xxxxx-dot-microservice-qa.appspot.com]
[INFO] GCLOUD:
[INFO] GCLOUD:
[INFO] GCLOUD: If this is your first deployment, this may take a while...
[INFO] GCLOUD: ....done.
[INFO] GCLOUD:
[INFO] GCLOUD: Beginning deployment of service [another-pub-sub-service]...
[INFO] GCLOUD: Building and pushing image for service [another-pub-sub-service]
[INFO] GCLOUD: ERROR: (gcloud.app.deploy) You do not have permission to access project [xxxx] (or it may not exist): The caller does not have permission
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.198s
[INFO] Finished at: Tue Sep 12 07:54:27 UTC 2017
[INFO] Final Memory: 21M/51M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:deploy (default-cli) on project demo-test1: Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:deploy failed: Non zero exit: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.1:deploy failed: Non zero exit: 1
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: com.google.cloud.tools.appengine.api.AppEngineException: Non zero exit: 1
        at com.google.cloud.tools.appengine.cloudsdk.process.NonZeroExceptionExitListener.onExit(NonZeroExceptionExitListener.java:30)
        at com.google.cloud.tools.appengine.cloudsdk.internal.process.DefaultProcessRunner.syncRun(DefaultProcessRunner.java:211)
        at com.google.cloud.tools.appengine.cloudsdk.internal.process.DefaultProcessRunner.run(DefaultProcessRunner.java:137)
        at com.google.cloud.tools.appengine.cloudsdk.CloudSdk.runGcloudCommand(CloudSdk.java:193)
        at com.google.cloud.tools.appengine.cloudsdk.CloudSdk.runAppCommandInWorkingDirectory(CloudSdk.java:136)
        at com.google.cloud.tools.appengine.cloudsdk.CloudSdkAppEngineDeployment.deploy(CloudSdkAppEngineDeployment.java:90)
        at com.google.cloud.tools.maven.DeployMojo.execute(DeployMojo.java:107)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        ... 20 more

我已经检查了服务器中用于运行 gcloud 命令的密钥/用户的权限,他们都有完整的权限。但是我仍然收到上述错误。

此外,Jenkins 中是否有任何其他插件或任何其他工具(例如用于管理构建和部署到应用引擎的 jenkins)来做同样的事情?

任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: maven google-app-engine spring-boot jenkins continuous-integration


    【解决方案1】:

    由于您的项目可能未配置您的 Jenkins 服务器,请在您的 jenkins 作业配置中使用以下命令:

    执行shell:

    #!/bin/sh
    gcloud -q auth activate-service-account --key-file=${PROJECT_KEY.JSON}
    gcloud -q config set project ${PROJECT_ID}
    mvn appengine:deploy
    

    此外,要在 Jenkins 服务器上使用“gcloud”,您必须在 Jenkins 中安装插件“Google Deployment Manager Jenkins Plugin”。

    【讨论】:

    • 感谢@Sonal Aggarwal。我已经在安装 Jenkins 的命令行中完成了这项工作。但是,从命令行本身运行“mvn appengine:deploy”会引发相同的错误。无法弄清楚可能是什么问题。
    • 你能把堆栈跟踪粘贴到这里吗?你现在看到同样的错误吗?
    • 是的,我现在也遇到了错误。我已经用详细的堆栈跟踪更新了这个问题。
    • 请检查命令 'gcloud config list --all | 的输出grep 帐户”。确保它使用的是同一个项目的服务帐号。
    • 是的,它显示:account = qa-service-account@project-qa.iam.gserviceaccount.com 您的活动配置是:[默认]。但是,我不确定 [default] 指向什么。
    猜你喜欢
    • 2020-10-21
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    • 2019-09-27
    • 1970-01-01
    • 2021-04-29
    • 1970-01-01
    • 2019-02-20
    相关资源
    最近更新 更多