2014-06-06 41 views
1

我開始通過詹金斯釋放過程中通過調用行家與運行在釋放一個maven配置文件:只准備

-Dresume=false clean release:prepare release:perform 

因爲我想前更改源代碼(添加目錄和文件,並承諾他們GIT)準備過程完成我只想在發佈:準備階段運行配置文件「doAtPrepare」。該配置文件已在正確的位置工作,但不幸地被稱爲兩次。一旦發佈:準備和發佈後:執行階段。後者在git中提交'detached head'時會產生錯誤。

對於在發行版中運行配置文件:僅執行階段在maven-release-plugin中有配置選項'releaseProfiles'。但我反過來需要它,直到現在還沒有找到解決方案。

我試着用profile.activation.properties(profile =!doAtPrepare),嘗試設置變量(-D)並用profile.activation.properties檢查它們,試圖檢查profile.activation.file中存在的文件(由於文件名包含$ {version}參數),因此試圖在jenkins命令行中使用-P(這會在兩個階段觸發配置文件)等等。

有沒有人可以幫助我找到一個工作解決方案?

回答

0

我發現了一種解決方法,但並非真正的解決方案。更好的建議仍然受歡迎。

首先,添加配置文件不所需的作業:未來

<profile> 
     <id>createNextDir</id> 
     <build> 
      <plugins> 
       <plugin> 
        <!-- whatever you want --> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 

,增加就業導向創建在目標目錄固定文件名的虛擬文件的配置文件:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.7</version> 
    <executions> 
     <execution> 
      <id>createNextDir1</id> 
      <phase>generate-sources</phase> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      <configuration> 
       <target> 
        <propertyfile file="target/done.lock" comment="Version ${project.version}"> 
        </propertyfile> 
       </target> 
      </configuration> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
      <groupId>ant-contrib</groupId> 
      <artifactId>ant-contrib</artifactId> 
      <version>20020829</version> 
     </dependency> 
    </dependencies> 
</plugin> 

最後一步是僅在文件不存在時才激活配置文件。請注意,在發佈期間:執行基目錄是目標/簽出/您的項目,因此需要引用正確的文件../../../yourproject/target/done.lock

<profile> 
    <id>createNextDir</id> 
    <activation> 
     <file> 
      <missing>../../../yourproject/target/done.lock</missing> 
     </file> 
    </activation> 
    <!-- Rest of profile --> 
</profile> 
相關問題