【发布时间】:2019-01-12 19:16:17
【问题描述】:
在与 Git(lab) 一起使用时,如何使用 Maven 'maven-release-plugin' 对简单项目执行“发布”?
我正在开发一个开发/功能分支,最后我将更新合并到“主”分支。我想,然后“发布”插件开始发挥作用。正确的?
在我的 Jenkinsfile 中,我调用:
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:git@gitlab.com:user/project.git</connection>
<developerConnection>scm:git:git@gitlab.com: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>
【问题讨论】:
-
出于某种原因,Maven 认为这是一个颠覆项目,而不是一个 git 项目。
-
首先,您应该使用最新版本的 maven-release-plugin (2.5.3) 此外,您永远不应该将 maven-release-plugin 与 pom 中的执行块绑定,因为它只能通过调用直接命令...所以需要版本和配置。同样奇怪的是@ThorbjørnRavnAndersen 已经提到的是为什么你会从 SVN 收到错误?
标签: git maven maven-release-plugin