简体   繁体   English

Maven发布插件git凭据

[英]Maven release plugin git credentials

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. 使用-Dusername-Dpassword更新每个作业(从而将密码存储在作业中)似乎不太可行。 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 (ie the release plugin prompts for credentials). 我已经读过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. 我无法相信一项简单且极为常见的任务,因为它没有简单的标准解决方案。

Based on the docs you 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 . BTW:检查您是否使用最新版本的maven-release-plugin The project.scm.id enhancement was introduced in version 2.3 as part of ticket MRELEASE-420 . project.scm.id增强功能是在2.3版本中作为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. 例如,如果您使用的是Maven 3.0.5,那么默认情况下您只使用maven-release-plugin的2.0版本。 Much too old. 太老了。 Fix by adding something like below to your POM: 通过在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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM