Maven 发布插件 git 凭证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28282572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven release plugin git credentials
提问by Rasmus Franke
We are using Jenkins and just switched from a file based git repo without authentication to using GitBlit with proper authentication over http.
我们正在使用 Jenkins 并且刚刚从没有身份验证的基于文件的 git repo 切换到使用 GitBlit 并通过 http 进行适当的身份验证。
The problem is - how is maven supposed to authenticate itself in batch mode?
问题是 - maven 应该如何在批处理模式下进行身份验证?
Updating each job with -Dusername
and -Dpassword
(and thus storing the password in the jobs) doesn't seem very feasible. I've read that settings.xml is supposed to work with git by specifying the git server as the id, but whatever I do it has no effect (i.e the release plugin prompts for credentials).
使用-Dusername
and更新每个作业-Dpassword
(从而将密码存储在作业中)似乎不太可行。我已经读过 settings.xml 应该通过将 git 服务器指定为 id 来与 git 一起使用,但无论我做什么都没有效果(即发布插件提示输入凭据)。
pom.xml:
pom.xml:
<properties>
<project.scm.id>git</project.scm.id>
</properties>
<scm>
<connection>scm:git:http://myserver:8081/r/gitauthtest.git</connection>
<developerConnection>scm:git:http://myserver:8081/r/gitauthtest.git</developerConnection>
</scm>
settings.xml contents
settings.xml 内容
<settings>
<servers>
<server>
<id>git</id>
<username>myUser</username>
<password>myPassword</password>
</server>
</servers>
</settings>
Is there any way to get this working? I cannot believe that a task as simple and extremely common as this doesn't have an easy standard solution.
有没有办法让这个工作?我无法相信像这样简单且极其常见的任务没有简单的标准解决方案。
回答by khmarbaise
Based on the docsyou have to use a special property, project.scm.id
, to define the id of the appropriate server entry in your settings.xml file.
根据文档,您必须使用特殊属性 ,project.scm.id
来定义settings.xml 文件中相应服务器条目的 id 。
<properties>
<project.scm.id>my-scm-server</project.scm.id>
</properties>
And the following in your settings.xml file:
以及 settings.xml 文件中的以下内容:
<settings>
<servers>
<server>
<id>my-scm-server</id>
<username>myUser</username>
<password>myPassword</password>
</server>
</servers>
</settings>
BTW: Check if you are using the most recent version of maven-release-plugin. The project.scm.id enhancement was introduced in version 2.3 as part of ticket MRELEASE-420. For example if you are using Maven 3.0.5 then you are by default only using version 2.0 of the maven-release-plugin. Much too old. Fix by adding something like below to your POM:
顺便说一句:检查您是否使用最新版本的maven-release-plugin。project.scm.id 增强是在 2.3 版中作为票证 MRELEASE-420 的一部分引入的。例如,如果您使用的是 Maven 3.0.5,那么默认情况下您只使用 Maven-release-plugin 的 2.0 版。太老了。通过在 POM 中添加如下内容来修复:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>