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

hiz5n14c  于 2023-08-03  发布在  Jenkins
关注(0)|答案(6)|浏览(157)

在我将Jenkins升级到1.494之前,这是可行的。现在,当我使用build promotion插件将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文件中有creds:

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


不知道为什么突然停止工作与1.494。我逐步下调至1.491,但它仍然发生了。非常令人沮丧。

zujrkrfu

zujrkrfu1#

你已经通过降级证明了这不是一个纯粹的Jenkins问题。由于密码位于settings.xml中,请尝试从Jenkins mvn help:effective-settings中运行此命令。这将给予您运行时的设置以及密码是否在其中。
另外,请尝试检查<id>snapshots</id><username>deployment</username>的拼写。我今天在某个地方遇到了这个错误,其中用户是releases而不是release,并且maven给出了forbidden错误

js4nwp54

js4nwp542#

我建议安装Config File Provider plugin,它提供了一个很好的GUI来编辑配置文件(比如Maven设置文件)的内容。
在配置构建时,使用“-s”选项告诉Maven使用以下配置文件之一:

mvn -s $MY_PROJECTS_MAVEN_SETTINGS ???

字符串
这种方法的优点是,您可以确保构建使用的是您的设置,而不是从文件系统中取出的某个随机文件。第二个好处是,每个项目现在可以轻松地拥有自己特定的Maven设置(例如,每个项目很可能有不同的凭据)。

sh7euo9m

sh7euo9m3#

我想出了解决这个问题的办法,但我还是不知道它是怎么开始的。
我在Archiva中创建了第三个用户,并将其设置为用户不必在第一次登录时更改密码。然后,我用这个新用户更新了Jenkins中的settings.xml。
它现在起作用了。
我仍然不知道为什么它停止与原始用户虽然工作。
感谢大家的帮助。

np8igboo

np8igboo4#

谢谢你跟进你的解决方案Oggie。我只是遇到了同样的症状,并克服了与您的新用户修复.
更多信息:我可以通过删除旧用户并创建一个具有完全相同的用户名和密码的新用户来使旧用户名和密码正常工作。(虽然我在一路沿着用相同/不同的密码试验了一个新用户)。
关于起因…我不知道。我们在与UberSVN相同的机器上运行Archiva,我们的Jenkins作为插件位于UberSVN中。这些都没有升级。然而,服务器上的各个目录的所有权发生了一些变化,尽管我看不出这些是原因,因为解决方案只是简单地创建一个新用户。
再次感谢你的帖子。

u59ebvdq

u59ebvdq5#

在重新创建我的Archiva存储库后,我错过了为部署用户分配Role RepositoryManager。添加角色后,它解决了上传工件时的401。
请参阅Archiva User Guide

mccptt67

mccptt676#

我也有同样的问题,根据Jenkins报告给帮助台的问题,也有可能是你的帐户有问题(基础设施问题)。
验证https://www.jenkins.io/doc/developer/publishing/releasing-manually/,如果你发现你的Jenkins帐户有什么奇怪的地方,试试https://github.com/jenkins-infra/helpdesk

相关问题