1

我们正试图让M2 Release Plugin将发布的工件部署到我们的Artifactory服务器。在我们pom.xml的配置看起来像这样为什么Jenkins上的M2 Release Plugin没有通过Artifactory验证?

.... 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-release-plugin</artifactId> 
    <version>2.3.2</version> 
</plugin> 
.... 
<distributionManagement> 
    <repository> 
     <id>artifactory</id> 
     <url>http://example.com/artifactory/jenkins-release</url> 
    </repository> 
</distributionManagement> 

使用Config File Provide Plugin我们指定一个全球性的settings.xml用正确的凭据

<settings> 
    <servers> 
     <server> 
      <id>artifactory</id> 
      <username>jenkins</username> 
      <password>secret!</password> 
     </server> 
    </servers> 
</settings> 

如果我们现在就詹金斯开始发布版本,Maven的告诉我们,它收到来自Artifactory的HTTP 401

[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project example-maven-plugin: Failed to deploy artifacts: Could not transfer artifact com.example.maven.plugins:example-maven-plugin:jar:0.0.9 from/to artifactory (http://example.com/artifactory/jenkins-release): Failed to transfer file: http://example.com/artifactory/jenkins-release/com/example/maven/plugins/example-maven-plugin/0.0.9/example-maven-plugin-0.0.9.jar. Return code is: 401, ReasonPhrase:Unauthorized. -> [Help 1] 

在服务器日志中,我们看到用户“non_authenticated_user”i试图对这个URL做一个HTTP PUT请求。

在Maven或Jenkins中是否存在一些我们错过的配置?凭据是正确的,如果我在我的本地机器上使用Jenkins的settings.xml,一切都按预期工作。

+0

看起来Jenkins没有拿起您提供的设置文件。不知道为什么,以及一些不相关的话题,为什么不使用[Artifactory Jenkins插件](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin)?它完全解决了这个问题,并具有内置的发布功能。 – JBaruch

+0

这就是我们想的,也许是插件中的一个错误,但我想确保我们不会错过任何东西。 我们使用这个插件,但仅用于SNAPSHOT构建的自动部署。我们发现这个插件的发布管理缺乏Jenkins M2发布插件的一些功能(例如,单独向SCM写入凭据,区分发布版本/非发布buids,...) – moxn

+1

您可以完全自定义发布的逻辑通过使用[staging用户插件](http://www.jfrog.com/confluence/display/RTF/User+Plugins#UserPlugins-Staging)。一些例子在[我们的GitHub](https://github.com/JFrogDev/artifactory-user-plugins) – JBaruch

回答

1

在2.2.2之前有a bug in the Maven release plugin,这使得它忽略配置文件提供程序传递给Maven的设置文件。解决的办法是在您的项目pom.xml中指定一个更新的maven release插件,如下所示:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.4.2</version> 
     </plugin> 
    </plugins> 
</build> 
+0

感谢您的回复,但我们当时正在使用2.3.2。 – moxn

+0

Doh,现在在您的问题中看到了版本号!除此之外,你的问题的描述与我的完全一样,所以我想我会留下我的回答,以防别人帮助别人。 – robpvn

+0

Upvoting这个答案,因为它在一个相关但略有不同的上下文中为我们解决了一个问题。在另一个模块中,我们没有为这个插件设置版本,所以Maven使用了2.7.x.切换回2.4.1解决了这个问题。 – moxn

相关问题