【发布时间】:2018-12-02 10:25:03
【问题描述】:
我怀疑这很简单,但我无法从 Maven 命令行或 Eclipse 将任何项目部署到远程 Artifactory 存储库。我可以使用 Artifactory Web UI 成功部署,但是当我在 Maven settings.xml 文件中指定相同的用户帐户('admin')时,它会失败并显示“错误代码 403,禁止访问”。我正在使用 Artifactory 的开源版本,版本 5.11.0。 “密码加密策略”设置为“必需”。
这是~/.m2/settings.xml文件中的服务器sn-p:
<server>
<id>dmrepo</id>
<username>admin</username>
<password>encrypted password obtained from the Artifactory UI</password>
</server>
这里是项目pom.xml 文件的部署部分:
<distributionManagement>
<repository>
<id>dmrepo</id>
<name>myrepo-releases</name>
<url>http://server:port/libs-release-local</url>
</repository>
</distributionManagement>
如果我使用-e 参数重新运行mvn,堆栈跟踪中的最后一个错误是:
原因:org.apache.maven.wagon.authorization.AuthorizationException:访问被拒绝:http://server:port/libs-release-local/path/to/jar/jarFile-version.jar,ReasonPhrase:禁止访问。
当我查看 Artifactory 和 Tomcat 日志文件时,我看到在失败的部署尝试期间完全没有记录任何内容,这让我想知道请求是否甚至到达了该服务器,但错误代码 403 是一个活动的“你可以't do that" 来自 somewhere 的响应,而不是一般的“无法访问该 URL”错误。此外,我可以在同一台机器上使用浏览器访问相同的主机和端口组合,所以我认为这不是防火墙问题。
我已经查看了其他类似的问题,但似乎都没有解决这种特定情况。 JFrog 用户指南建议检查存储库上的包含和排除过滤器,但包含设置为 **/* 并且排除为空白,这对我来说似乎是正确的。用户指南中的另一个建议是“权限”可能是问题所在,但它没有说明哪些权限或如何检查和更改它们。
更新
更新了@Ariel 请求的curl 命令的(轻微编辑的)输出:
curl -i -vvv -u 'admin:<password>' -T <filename.jar> <hostname>:<port>/<repo_name>/<package>/<version>/<filename>
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying <IP_address>...
* TCP_NODELAY set
* Connected to <hostname> (<IP_address>) port <port> (#0)
* Server auth using Basic with user 'admin'
> PUT /<repo_name>/<package>/<version>/<filename> HTTP/1.1
> Host: <hostname>:<port>
> Authorization: Basic <Base64_encoded admin:password>
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 14364
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue
} [14364 bytes data]
* We are completely uploaded and fine
< HTTP/1.1 403 Forbidden
HTTP/1.1 403 Forbidden
< Content-Type: text/html;charset=utf-8
Content-Type: text/html;charset=utf-8
< Content-Language: en
Content-Language: en
< Content-Length: 983
Content-Length: 983
< Date: Wed, 27 Jun 2018 00:26:15 GMT
Date: Wed, 27 Jun 2018 00:26:15 GMT
< Connection: close
Connection: close
<
{ [983 bytes data]
100 15347 100 983 100 14364 6380 93227 --:--:-- --:--:-- --:--:-- 93272
* Closing connection 0
<!doctype html><html lang="en"><head><title>HTTP Status 403 – Forbidden</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 403 – Forbidden</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The server understood the request but refuses to authorize it.</p><hr class="line" /><h3>Apache Tomcat/8.5.23</h3></body></html>
【问题讨论】:
-
您能否尝试在不加密的情况下先从命令行访问工件,如果这比加密更有效...此外,您是否正确配置了
settings-security.xml...?您使用哪个 Maven 版本? -
您在 Artifactory 的“request.log”中看到了什么?这也应该给你一些信息。
-
另外,您可以尝试使用 curl 命令部署相同的文件,看看是否有效?只是试图缩小问题的范围。使用 'curl -u admin:password -T filename server:port/libs-release-local/path/to/jar/jarFile-version.jar' 替换用户名和密码,路径和文件名... :)
-
@Ariel & @khmarbaise:感谢您的建议。使用 curl 还会给出 403 错误代码,并且使用未加密的密码。
request.log文件中什么都没有。settings-security.xml文件在哪里?我不认识那个文件名。 -
@DaveMulligan 请再次运行 curl 并添加以下标志:-i -vvv 请将 curl 命令的输出添加到此线程。
标签: maven artifactory