[英]Why does M2 Release Plugin on Jenkins not authenticate to Artifactory?
我們正在嘗試獲取M2發布插件,以將發布的工件部署到我們的Artifactory服務器。 pom.xml
的配置如下所示
....
<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>
使用配置文件提供插件,我們使用適當的憑據指定了一個全局settings.xml
<settings>
<servers>
<server>
<id>artifactory</id>
<username>jenkins</username>
<password>secret!</password>
</server>
</servers>
</settings>
如果我們現在在Jenkins上啟動發布版本,Maven告訴我們那里已經收到了來自工件的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”正在嘗試對此URL進行HTTP PUT請求。
我們缺少Maven或Jenkins中的某些配置嗎? 憑據是正確的,如果我在本地計算機上使用Jenkins的settings.xml,則一切正常。
2.2.2之前的Maven版本插件中存在一個錯誤,該錯誤使它忽略了由配置文件提供程序傳遞給Maven的設置文件。 解決方案是在項目pom.xml中指定一個較新的Maven版本插件,如下所示:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
</plugin>
</plugins>
</build>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.