2015-12-21 90 views
5

我跟进“https://cloud.google.com/tools/cloud-repositories/docs/push-to-deploy”打造我的第一个测试项目,但是当我做MVN gcloud:部署[错误gcloud app命令退出代码为:1]

“MVN gcloud:部署”

,我得到下面的错误詹金斯控制台:

[workspace] $ /opt/bitnami/apps/jenkins/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/jenkins-maven/bin/mvn clean install gcloud:deploy 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building jenkins-test-java 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jenkins-test-java --- 
[INFO] Deleting /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/target 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jenkins-test-java --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/src/main/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ jenkins-test-java --- 
[INFO] No sources to compile 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jenkins-test-java --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/src/test/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ jenkins-test-java --- 
[INFO] No sources to compile 
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jenkins-test-java --- 
[INFO] No tests to run. 
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ jenkins-test-java --- 
[WARNING] JAR will be empty - no content was marked for inclusion! 
[INFO] Building jar: /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/target/jenkins-test-java-1.0-SNAPSHOT.jar 
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ jenkins-test-java --- 
[INFO] Installing /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/target/jenkins-test-java-1.0-SNAPSHOT.jar to /home/tomcat/.m2/repository/com/google/appengine/demos/jenkins-test-java/1.0-SNAPSHOT/jenkins-test-java-1.0-SNAPSHOT.jar 
[INFO] Installing /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/pom.xml to /home/tomcat/.m2/repository/com/google/appengine/demos/jenkins-test-java/1.0-SNAPSHOT/jenkins-test-java-1.0-SNAPSHOT.pom 
[INFO] 
[INFO] >>> gcloud-maven-plugin:2.0.9.90.v20151210:deploy (default-cli) > package @ jenkins-test-java >>> 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jenkins-test-java --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/src/main/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ jenkins-test-java --- 
[INFO] No sources to compile 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ jenkins-test-java --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/src/test/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ jenkins-test-java --- 
[INFO] No sources to compile 
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ jenkins-test-java --- 
[INFO] No tests to run. 
[INFO] Skipping execution of surefire because it has already been run for this configuration 
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ jenkins-test-java --- 
[WARNING] JAR will be empty - no content was marked for inclusion! 
[INFO] 
[INFO] <<< gcloud-maven-plugin:2.0.9.90.v20151210:deploy (default-cli) < package @ jenkins-test-java <<< 
[INFO] 
[INFO] --- gcloud-maven-plugin:2.0.9.90.v20151210:deploy (default-cli) @ jenkins-test-java --- 
[INFO] Running gcloud app deploy... 
[INFO] Running python -S /usr/local/share/google/google-cloud-sdk/lib/googlecloudsdk/gcloud/gcloud.py --quiet --project=jenkins-test-java preview app deploy /opt/bitnami/apps/jenkins/jenkins_home/jobs/dev-jenkins-test/workspace/target/appengine-staging/app.yaml 
[INFO] You do not currently have this command group installed. Using it 
[INFO] requires the installation of components: [preview] 
[INFO] ERROR: (gcloud) You cannot perform this action because you do not have permission to modify the Google Cloud SDK installation directory [/usr/local/share/google/google-cloud-sdk]. 
[INFO] 
[INFO] Re-run the command with sudo: sudo gcloud ... 
[ERROR] Error: gcloud app command with exit code : 1 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.628 s 
[INFO] Finished at: 2015-12-21T06:29:47+00:00 
[INFO] Final Memory: 11M/56M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal com.google.appengine:gcloud-maven- plugin:2.0.9.90.v20151210:deploy (default-cli) on project jenkins-test-java: Error: gcloud app command exit code is: 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/MojoExecutionException 
Build step 'Invoke top-level Maven targets' marked build as failure 
Finished: FAILURE 

,我的pom.xml的是:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.google.appengine.demos</groupId> 
    <artifactId>jenkins-test-java</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <properties> 
    <appengine.target.version>1.9.28</appengine.target.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
    <!-- Compile/runtime dependencies --> 
    <dependency> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>appengine-api-1.0-sdk</artifactId> 
     <version>${appengine.target.version}</version> 
    </dependency> 
    </dependencies> 

<build> 
    <!-- needed for enabling compile/reload on save in mordern IDEs...--> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <version>2.5.1</version> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <configuration> 
      <source>1.7</source> 
      <target>1.7</target> 
     </configuration> 
    </plugin> 
    <plugin> 
     <groupId>com.google.appengine</groupId> 
     <artifactId>gcloud-maven-plugin</artifactId> 
     <version>2.0.9.90.v20151210</version> 
     <configuration> 
      <gcloud_project>jenkins-test-java</gcloud_project> 
     </configuration> 
    </plugin> 
    </plugins> 
</build> 
</project> 

谢谢你们:)

回答

2

错误说明了一切:

ERROR: (gcloud) You cannot perform this action because you do not have permission to modify the Google Cloud SDK installation directory
[/usr/local/share/google/google-cloud-sdk].

我看到三个选项:

  • 运行该命令使用sudo或作为根。
  • 让你的谷歌云-SDK目录(在/ usr/local/share下/谷歌/谷歌云SDK)可写为用户
  • 安装谷歌云-SDK的地方在那里你的用户有写权限和执行命令等(参见docs):

    mvn gcloud:run -Dgcloud.gcloud_directory="absolute-path-to-the-gcloud-directory" 
    
  • 的地方在那里你的用户有写权限,并设置gcloud目录在你的pom.xml安装谷歌云-SDK(见docs):

    <plugin> 
        <groupId>com.google.appengine</groupId> 
        <artifactId>gcloud-maven-plugin</artifactId> 
        <version>>2.0.9.72.v20150804</version> 
        <configuration> 
        <gcloud_directory>/usr/foo/private/google-cloud-sdk</gcloud_directory> 
        ... 
    
+0

感谢konqi为您的答案,我得到的原因是1.更改文件夹“/ usr/local/share/google/google-cloud-sdk”的权限可写入所有用户。 2.使用 my_google_project_id修改“pom.xml” –

相关问题