如何在使用Hudson/Jenkins这样的CI工具时,成功地将Maven发布插件与GitHub(或GitHub企业版)配合使用
遇到的问题包括:
- 如果pom.xml在子文件夹中而不是顶层,则Maven不会提交。由于这个问题,后续构建会因标签名称已存在而失败。
- 尽管在运行CI作业的源服务器之间设置了公钥身份验证,但git push仍然会失败并显示以下错误之一
- 公钥身份验证失败
- 未知服务git
如何在使用Hudson/Jenkins这样的CI工具时,成功地将Maven发布插件与GitHub(或GitHub企业版)配合使用
遇到的问题包括:
For the sub-folder commit of pom.xml to work, the bug is resolved in Maven release plug-in 2.5.1. Get the latest with the dependencies. The below section shows the pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.2</version>
</dependency>
</dependencies>
<configuration>
<checkModificationExcludes>
<checkModificationExclude>pom.xml</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
Correctly configure the SCM section in pom.xml. For public key authentication to work, use SSH protocol. For https protocol, user/password will be needed, this answer does not cover that. It should be possible by providing user/pwd in the Maven settings.xml in the servers section.
<scm>
<developerConnection>scm:git:ssh://github.com/org/repo.git</developerConnection>
<url>https://github.com/org/repo</url>
<tag>HEAD</tag>
</scm>
Create a user called git in your source server. If you run as any other user, the developerConnection url will need to have git@github.com in stead of github.com. Maven will try to put a git:****** in the git push command and it fails as service unknown. If you use any other user to SSH into github, it will reject with public key authentication failed.
Using the git as user, generate SSH keys and configure following the simple steps below
Edit your Hudson/Jenkins job as below
请使用maven命令 clean compile release:prepare和release:perform运行您的工作。这应该有效。