2013-01-18 24 views
2

我試圖使用maven SCM plugin自動化構建過程中犯了一些文件到混帳回購協議,該插件需要將其設置爲系統屬性提交消息,我不希望有這個消息傳給其他的命令行(我也使用釋放插件,這會導致問題)。如何在使用scm-maven-plugin時在pom中指定提交消息?

我用盡了一切我想通過POM,但沒有運氣要添加的消息系統屬性,這是我的聚甲醛的一個精簡版:

<?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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.monkeys.coding</groupId> 
    <artifactId>project</artifactId> 
    <packaging>js</packaging> 
    <version>1.0.4-SNAPSHOT</version> 

    <name>Some Project</name> 
    <description>Some Project where I want to add files to git during build</description> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <projectVersion>${project.version}</projectVersion> 
    </properties> 

    <scm> 
     <connection>scm:git:http://some.git.repo:9080/git/module.git</connection> 
     <developerConnection>scm:git:http://some.git.repo:9080/git/module.git</developerConnection> 
     <url>http://some.git.repo:9080/git/module.git</url> 
    </scm> 

    <build> 
     <finalName>${project.artifactId}</finalName> 
     <!-- Package as js --> 
     <extensions> 
      <extension> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>javascript-maven-plugin</artifactId> 
       <version>2.0.0-alpha-1</version> 
      </extension> 
     </extensions> 
    ... 
    </build> 

    <profiles> 
     <!-- run this profile when releasing the library --> 
     <profile> 
      <id>release</id> 
      <properties> 
       <message>Add version files to git</message> 
      </properties> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-scm-plugin</artifactId> 
         <version>1.8.1</version> 
         <configuration> 
          <message>Add version files to git</message> 
          <systemProperties> 
           <systemProperty> 
            <name>message</name> 
            <value>[Add Version to git]</value> 
           </systemProperty> 
          </systemProperties> 
         </configuration> 
         <executions> 
          <execution> 
           <id>add-version-to-git</id> 
           <phase>package</phase> 
           <goals> 
            <goal>add</goal> 
            <goal>checkin</goal> 
           </goals> 
           <configuration> 
            <basedir>./</basedir> 
            <includes>versions/*</includes> 
            <systemProperties> 
             <systemProperty> 
              <name>message</name> 
              <value>[Add Version to git]</value> 
             </systemProperty> 
            </systemProperties> 
           </configuration> 
          </execution> 
         </executions> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 
    </profiles> 
</project> 

通過配置文件屬性添加消息似乎工作,文件上犯下得到該消息出現在回購,但構建失敗,此錯誤:

[ERROR] Provider message: 
    [ERROR] The git-commit command failed. 
    [ERROR] Command output: 
    [ERROR] 
    [INFO] ------------------------------------------------------------------------ 
    [INFO] BUILD FAILURE 
    [INFO] ------------------------------------------------------------------------ 
    [INFO] Total time: 28.637s 
    [INFO] Finished at: Fri Jan 18 12:59:40 GMT 2013 
    [INFO] Final Memory: 19M/81M 
    [INFO] ------------------------------------------------------------------------ 
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.8.1:checkin (add-version-to-git) on project: Command failed.The git-commit command failed. -> [Help 1] 

什麼我做錯了任何想法?

乾杯 羅布

回答

5

嘗試改變pom.xml看起來像這樣:

... 
    <executions> 
     <execution> 
      <id>add-version-to-git</id> 
      <phase>package</phase> 
      <goals> 
       <goal>add</goal> 
       <goal>checkin</goal> 
      </goals> 
      <configuration> 
       <basedir>./</basedir> 
       <includes>versions/*</includes> 
       <message>[Add Version to git]</message> 
      </configuration> 
     </execution> 
    </executions> 
... 

嘗試使用message屬性,而不是systemProperties

或者你總是可以做到這一點的命令行,如:

mvn -Dmessage="<commit_log_here>" scm:checkin 

如說here

+0

由於我使用最多的建議,誰運行我們的CI服務器的人往往亂用MVN命令我們設置,所以我不想添加它在命令行:) –

相關問題