发布到Artifactory时SBT没有通过凭据 [英] SBT not passing credentials when publishing to Artifactory

查看:220
本文介绍了发布到Artifactory时SBT没有通过凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编码Java项目,并使用SBT将构建和发布自动化到JFrog Artifactory.

I am coding a Java project and I'm automating the build and the publishing to JFrog Artifactory using SBT.

每当要发布到Artifactory时,我都想使用Ivy目录布局来完成它,并且显然要与jar一起发布Ivy XML文件.我通过在build.sbt文件中使用以下几行来实现这一目标:

Whenever it's time to publish to Artifactory I want to do it using the Ivy directory layout and obviously publish the Ivy XML file along with the jar. I managed to achieve this by using the following lines in the build.sbt file:

crossPaths := false
publishTo := Some("Artifactory Realm" at "http://<Artifactory IP>:<Artifactory Port>/artifactory/org.project.my")
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
publishMavenStyle := false

但是,仅当允许匿名用户部署到Artifactory中时,此方法才有效.我意识到sbt并没有真正将我的凭据传递给Artifactory,而是以匿名身份登录.

However it only works when anonymous users are allowed to deploy into Artifactory. I realized that sbt is not really passing my credentials to Artifactory but, instead, logging in as anonymous.

我的$HOME/.ivy2/.credentials文件如下所示:

realm=Artifactory Realm
host=http://<Artifactory IP>:<Artifactory Port>/artifactory/org.project.my
user=<my user name>
password=<my user name>

但是,如果我更改Artifactory配置以防止匿名用户部署新的Artifacts,则在运行"sbt publish"时会得到以下输出:

However, if I change the Artifactory configuration in order to prevent anonymous users from deploying new Artifacts, when I run "sbt publish" I get the following output:

[error] Unable to find credentials for [Artifactory Realm @ <Artifactory IP>].
java.io.IOException: Access to URL http://<Artifactory IP>:<Artifactory Port>/artifactory//org.project.my/org/project/my/project-my/1.0.0/project-my-1.0.0.jar was refused by the server: Unauthorized

Artifactory request.log文件随后包含:

The Artifactory request.log file then contains:

20160219011657|319|REQUEST|10.0.2.2|anonymous|PUT|/org.project.my/org/project/my/project-my/1.0.0/project-my-1.0.0.jar|HTTP/1.1|401|24978

我还尝试过手动传递凭据,而不使用文件:

I have also tried passing the credentials manually instead of using a file:

credentials += Credentials("Artifactory Realm", "localhost", "<USERNAME>", "<PASS>")

但是我得到相同的结果.

But I am getting the same result.

知道我可能会缺少什么吗?

Any idea what I might be missing?

推荐答案

尝试:

host=<Artifactory IP>

旧答案(无效):

host=<Artifactory IP>:<Artifactory port>

这篇关于发布到Artifactory时SBT没有通过凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆