2015-10-20 91 views
0

我在Bitbucket上有一個Git項目,我試圖用mvn release:prepare命令發佈它,但我得到了以下異常。使用maven發佈命令發佈基於java的git項目

據我所知,它是要求我的密碼,但不知道在哪裏以及如何指定它。

錯誤日誌:

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 20.355 s 
[INFO] Finished at: 2015-10-20T12:17:04-04:00 
[INFO] Final Memory: 13M/166M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare (default-cli) on project git-cicd-demo: Unable to tag SCM 
[ERROR] Provider message: 
[ERROR] The git-push command failed. 
[ERROR] Command output: 
[ERROR] bash: /dev/tty: No such device or address 
[ERROR] error: failed to execute prompt script (exit code 1) 
[ERROR] fatal: could not read Password for 'https://[email protected]': Invalid argument 
[ERROR] -> [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/MojoFailureException 

的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.study.git.cicd</groupId> 
    <artifactId>git-cicd-demo</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <!-- VCS integration --> 
    <scm> 
     <connection>scm:git:https://[email protected]/nitalchandel/git-cicd-demo.git</connection> 
     <url>https://[email protected]/nitalchandel/git-cicd-demo</url> 
     <developerConnection>scm:git:https://[email protected]/nitalchandel/git-cicd-demo.git</developerConnection> 
    </scm> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <maven.compiler.source>1.7</maven.compiler.source> 
     <maven.compiler.target>1.7</maven.compiler.target> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.10</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.jacoco</groupId> 
       <artifactId>jacoco-maven-plugin</artifactId> 
       <version>0.7.5.201505241946</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>prepare-agent</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>report</id> 
         <phase>prepare-package</phase> 
         <goals> 
          <goal>report</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

</project> 
+2

首先使用更新版本的[maven-release-plugin](http://maven.apache.org/maven-release/maven-release-plugin/)2.5.2 .... – khmarbaise

+1

你可以定義你的你的Maven設置中的git密碼。請參閱http://stackoverflow.com/questions/28282572/maven-release-plugin-git-credentials。順便說一句,如果你不想在文件中以純文本格式,你也可以加密這個密碼。 –

+0

@Gael - 我在我的settings.xml文件中添加了密碼,但不知道如何引用它。如何使用mvn發佈:prepare命令? – user2325154

回答

2

你應該能夠在命令行上指定口令:

mvn release:prepare -Dpassword=qwerty ... 

hererelease:prepare的全套選項。