如何在发行版中执行groovy脚本:仅执行

时间:2019-05-08 15:15:19

标签: maven groovy maven-release-plugin gmavenplus

我有一个Maven项目,詹金斯(Jenkins)推出了发布版本,

mvn -B release:prepare release:perform

pom包含使用gmavenplus-plugin执行的groovy脚本。启动发布版本时,将执行groovy脚本两次,一次执行release:prepare,一次执行release:perform。

如何仅在release:perform中执行groovy脚本?

据我所知,gmavenplus-plugin仅接受execute目标,并且所有阶段都在准备和执行目标中执行。我没有运气就尝试了很多目标和阶段。

这是我pom的样本:

<groupId>com.testgroovy</groupId>
<artifactId>myArtifactId</artifactId>
<version>4.1.1</version>

<packaging>pom</packaging>

<scm>
    <developerConnection>scm:svn:https://path.to.scm</developerConnection>
</scm>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>parse-version</id>
                    <goals>
                        <goal>parse-version</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.gmavenplus</groupId>
          <artifactId>gmavenplus-plugin</artifactId>
          <version>1.6.1</version>
          <executions>
            <execution>
              <id>attach</id>
              <configuration>
                <scripts>
                  <script><![CDATA[
                        // MY GROOVY SCRIPT
                        println "  -- ####-####-    MY GROOVY SCRIPT    -####-#### --\n";
                  ]]></script>
                </scripts>
              </configuration>
              <goals>
                <goal>execute</goal>
              </goals>
              <phase>package</phase>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy-all</artifactId>
              <version>2.3.3</version>
            </dependency>
          </dependencies>
        </plugin>           
    </plugins>
</build>

0 个答案:

没有答案