现在,当将工件部署到archiva maven repo时,在jenkins中获得401未授权

时间:2012-12-24 16:48:43

标签: maven jenkins maven-plugin archiva

在我将Jenkins升级到1.494之前,这曾经工作过。现在,当我使用构建促销插件将war工件复制到快照仓库时,我在Jenkins中收到此错误:

    ERROR: Failed to deploy artifacts: Could not transfer artifact com.blah.data:RestWebServices:war:1.0-20121224.163825-2 from/to archiva.apache.snapshots (http://10.31.31.64:8080/archiva/repository/snapshots): Failed to transfer file: http://10.31.31.64:8080/archiva/repository/snapshots/com/blah/data/RestWebServices/1.0-SNAPSHOT/RestWebServices-1.0-20121224.163825-2.war. Return code is: 401, ReasonPhrase:Unauthorized.
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact com.blah.data:RestWebServices:war:1.0-20121224.163825-2 from/to archiva.apache.snapshots (http://10.31.31.64:8080/archiva/repository/snapshots): Failed to transfer file: http://10.31.31.64:8080/archiva/repository/snapshots/com/blah/data/RestWebServices/1.0-SNAPSHOT/RestWebServices-1.0-20121224.163825-2.war. Return code is: 401, ReasonPhrase:Unauthorized.
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
    at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:190)
    at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:173)
    at hudson.plugins.promoted_builds.Promotion$RunnerImpl.build(Promotion.java:187)
    at hudson.plugins.promoted_builds.Promotion$RunnerImpl.doRun(Promotion.java:141)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:586)
    at hudson.model.Run.execute(Run.java:1543)
    at hudson.model.Run.run(Run.java:1489)
    at hudson.plugins.promoted_builds.Promotion.run(Promotion.java:106)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.blah.data:RestWebServices:war:1.0-20121224.163825-2 from/to archiva.apache.snapshots (http://10.31.31.64:8080/archiva/repository/snapshots): Failed to transfer file: http://10.31.31.64:8080/archiva/repository/snapshots/com/blah/data/RestWebServices/1.0-SNAPSHOT/RestWebServices-1.0-20121224.163825-2.war. Return code is: 401, ReasonPhrase:Unauthorized.
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:280)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    ... 10 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact com.blah.data:RestWebServices:war:1.0-20121224.163825-2 from/to archiva.apache.snapshots (http://10.31.31.64:8080/archiva/repository/snapshots): Failed to transfer file: http://10.31.31.64:8080/archiva/repository/snapshots/com/blah/data/RestWebServices/1.0-SNAPSHOT/RestWebServices-1.0-20121224.163825-2.war. Return code is: 401, ReasonPhrase:Unauthorized.
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:951)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:837)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:467)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:274)
    ... 13 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://10.31.31.64:8080/archiva/repository/snapshots/com/blah/data/RestWebServices/1.0-SNAPSHOT/RestWebServices-1.0-20121224.163825-2.war. Return code is: 401, ReasonPhrase:Unauthorized.
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:613)
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:509)
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:490)
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:470)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:811)
    ... 15 more

我在settings.xml文件中有信用:

<server>
      <id>snapshots</id>
      <username>deployment</username>
      <password>deployment</password>
    </server>

不确定为什么突然停止使用1.494。我逐步降级到1.491但它仍然发生了。非常令人沮丧。

5 个答案:

答案 0 :(得分:12)

您已经通过降级证明了自己这不是纯粹的Jenkins问题。由于密码位于settings.xml中,因此请尝试在Jenkins mvn help:effective-settings中运行此密码。这将为您提供运行时的确切设置以及密码是否在那里。

同时尝试检查<id>snapshots</id><username>deployment</username>的拼写。我今天在某个地方遇到了这个错误,用户是releases而不是release而且maven正在提供禁止错误

答案 1 :(得分:3)

我建议安装Config File Provider plugin,它提供了一个很好的GUI来编辑配置文件的内容(例如Maven设置文件)

配置构建时,使用“-s”选项告诉Maven使用以下配置文件之一:

mvn -s $MY_PROJECTS_MAVEN_SETTINGS ???

这种方法的优点是您确定构建使用的是您的设置,而不是一些随机文件,它可能会取消文件系统。第二个好处是每个项目现在可以轻松拥有自己的特定Maven设置(例如,每个项目很可能具有不同的凭据)。

答案 2 :(得分:2)

我想出了如何解决这个问题,但我仍然不知道它是如何发生的。

我在Archiva中创建了第三个用户,并进行了设置,因此用户无需在首次登录时更改密码。然后我用新用户更新了Jenkins中的settings.xml。

它现在有效。

我仍然不知道它为什么停止与原始用户合作。

感谢大家的帮助。

答案 3 :(得分:0)

感谢您跟进解决方案Oggie。我刚刚遇到了相同的症状并且已经克服了新的用户修复程序。

更多信息: 通过删除旧用户并创建具有完全相同用户名和密码的新用户,我能够获得旧的用户名和密码。 (虽然我在路上尝试了一个具有相同/不同密码的新用户。)

关于原因...... 我不知道。我们在与UberSVN相同的机器上运行Archiva,我们的Jenkins作为插件位于UberSVN内部。没有升级任何这些。然而,对服务器上的各种目录进行了许多所有权更改,但鉴于解决方案只是创建一个新用户,我无法看到这些更改。

再次感谢您的帖子。

答案 4 :(得分:0)

在重新创建Archiva存储库后,我错过了为部署用户提供角色RepositoryManager。添加角色后,它在上传工件时解决了401。

Archiva User Guide