在使用Git(实验室)时,如何使用Maven'maven-release-plugin'在一个简单的项目上执行'发布'?
我正在开发dev / feature分支,最后我将更新合并到'master'分支。我猜,那么'发布'插件就会发挥作用。正确?
在我的Jenkins文件中,我打电话给:
sh 'mvn release:prepare release:perform'
尝试很多选项时,我不断收到此错误:
The svn command failed. [ERROR] Command output: [ERROR] svn: E155007: '..workspace/project/pom.xml' is not a working copy
失败的命令是:
[INFO] Executing: /bin/sh -c cd /var/jenkins_home/workspace/jenkins-testing-releasing && svn --non-interactive commit --file /tmp/maven-scm-1557766606.commit --targets /tmp/maven-scm-8208798121252708517-targets
[INFO] Working directory: /var/jenkins_home/workspace/jenkins-testing-releasing
奇怪,因为我不使用SVN。
这是我到目前为止:
<project ...
<artifactId>jenkinstesting</artifactId>
<version>0.1-SNAPSHOT</version>
<scm>
<connection>scm:git:[email protected]:user/project.git</connection>
<developerConnection>scm:git:[email protected]:user/project.git</developerConnection>
<tag>rel1</tag>
</scm>
版本1:
<build>
<plugins ...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>perform</goal>
</goals>
<configuration>
<pomFileName>pom.xml</pomFileName>
</configuration>
</execution>
</executions>
</plugin>
版本2:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
正如一些帖子中所建议的,使用Jgitflow Maven插件(确实)更好。甚至该项目也改为此插件。所以,没有理由坚持使用Maven Release插件。回顾过去,我终于同意了这个建议并继续使用Jgitflow插件。
发布步骤的结果是什么?假设开发分支的当前版本是0.5.0-SNAPSHOT。
需要采取哪些措施?
好的,给我看一下代码...... ;-)
def mavenHome = tool 'Maven Latest'
def nextVersion = // determine this on the requested major/minor/patch release
sh "${mavenHome}/bin/mvn clean -B jgitflow:release-start jgitflow:release-finish " +
"-DskipTests " +
"-DallowUntracked=true " +
"-DpushReleases=true " +
"-DscmCommentPrefix=[RELEASE]- " +
"-DenableSshAgent=true " +
"-DreleaseVersion=${nextVersion}"
确定下一个版本可以作为一个参数:主要,次要或补丁等。
准备工作是:使用GIT-flow时,您可以通过拉取请求将功能分支更改合并到开发分支中。