use*_*215 10 build artifactory maven jenkins
我正在尝试在单个Jenkins作业中构建多个Maven配置文件.每个配置文件修改一些代码,然后通过执行创建一个罐子mvn -Pdev install,然后mvn -Pprod install在命令行中(根据使用Maven mvn -Pdev,prod install应该工作,但它不工作对我来说).以下是我项目中的两个配置文件pom.xml:
<profiles>
<!-- prod profile -->
<profile>
<id>prod</id>
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>src/main/java/com/IQzone/android/configuration/AbstractHoldingRefreshable.java</file>
<replacements>
<replacement>
<token>TrUe</token>
<value>TOAST_SWITCH</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>prod</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- dev profile -->
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>src/main/java/com/IQzone/android/configuration/AbstractHoldingRefreshable.java</file>
<replacements>
<replacement>
<token>TOAST_SWITCH</token>
<value>TrUe</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- build project with JAVA 1.6 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>dev</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
如果构建的作业被命中,我如何设置Jenkins为单个Jenkins作业自动构建这两个配置文件?把这两个罐放在Artifactory中?我对詹金斯的知识很少,而且网上的信息也不多.
bla*_*ild 15
您可以创建一个Jenkins矩阵作业.矩阵作业允许在更改设置的情况下运行相同的作业(在您的情况下:字符串).
每个更改设置称为轴.在您的情况下,您将创建一个包含两个值的字符串轴:dev和prod.
这样你的工作就会两次运行两次.
但是:您使用配置文件很危险.由于用于运行构建的配置文件没有编入您的工件中,因此您可以打破"一个源代码修订应始终导致完全相同的目标工件"Maven合同(请参阅:http://www.blackbuild.com/how- to-really-use-maven-profiles-without-endangering-your-karma /更详细的解释)
考虑使用分类器(-dev和-prod)创建两个不同的工件甚至更好:创建构建的两个单独模块,每个模块仅创建一个目标工件.
cof*_*aks 11
在Maven中,如果使用mvn -Pdev,prod,则在一个命令中同时激活两个配置文件.
看起来你想要2个不同的命令运行,即你可以通过2个构建在命令行上实现的东西:
mvn -Pdev install; mvn -Pprod install
Run Code Online (Sandbox Code Playgroud)
在jenkins你可以用任何一种方法实现这一点
mvn -P$PROFILE install任务)