我们正试图让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,一切都按预期工作。
看起来Jenkins没有拿起您提供的设置文件。不知道为什么,以及一些不相关的话题,为什么不使用[Artifactory Jenkins插件](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin)?它完全解决了这个问题,并具有内置的发布功能。 – JBaruch
这就是我们想的,也许是插件中的一个错误,但我想确保我们不会错过任何东西。 我们使用这个插件,但仅用于SNAPSHOT构建的自动部署。我们发现这个插件的发布管理缺乏Jenkins M2发布插件的一些功能(例如,单独向SCM写入凭据,区分发布版本/非发布buids,...) – moxn
您可以完全自定义发布的逻辑通过使用[staging用户插件](http://www.jfrog.com/confluence/display/RTF/User+Plugins#UserPlugins-Staging)。一些例子在[我们的GitHub](https://github.com/JFrogDev/artifactory-user-plugins) – JBaruch