我們正試圖讓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