【问题标题】:SBT Basic Auth ProblemsSBT 基本身份验证问题
【发布时间】:2018-12-20 01:21:33
【问题描述】:

我正在我们的构建服务器(bamboo)上为多个构建代理设置 SBT。为此,我为每个代理创建了一个单独的目录,其中包含特定于代理的配置和 .ivy 主目录,以确保完全填充代理隔离。 构建本身是这样调用的:

/sbt-launcher-packaging-0.13.13/bin/sbt -java-home /usr/lib/jvm/jdk1.7.0_79 -Dsbt.override.build.repos=true -Dsbt.repository.config=/data/bamboo/localbuildagents/${bamboo.agentId}/sbt/sbt.conf -Dsbt.ivy.home=/data/bamboo/localbuildagents/${bamboo.agentId}/.ivy2 clean compile dist

凭据(基本领域)存储在启动竹服务器的用户主目录下(~/.sbt/.credentials 和 ~/.sbt/0.13/plugins/credentials.sbt)

每个 sbt.conf 都包含特定于代理的 repos,例如特定于代理的本地 maven repo 和远程工件的 url。

[repositories]
  local-buildagent-mvn:  file:///data/bamboo/home/.m2/AGENT-xxxxxxxx/repository/
  ivy-release:   http://xxx/artifactory/ivy-release/,  [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
  mvn-release:   http://xxx/artifactory/libs-release/
  mvn-snapshot:  http://xxx/artifactory/libs-snapshot/  

[ivy]
  ivy-home:   file:///data/bamboo/localbuildagents/xxxxxxxx/.ivy2/

我在 sbt 检查远程工件存储库时遇到登录问题(首先是 http 错误 401,然后是令人惊讶的 403)。具有相同凭据和 repo url 的 curl 按预期工作(先是 401,然后是 200)。

我猜,如果 -D 开关用于 sbt 启动,则不考虑凭据。我真的卡住了任何建议,热烈欢迎......

【问题讨论】:

    标签: sbt bamboo


    【解决方案1】:

    根据您的问题,我看不出您是否指定了凭据的定义位置。如果您没有这样做,您必须在构建定义中添加类似这样的内容 (documentation):

    // inline
    credentials += Credentials("Some Nexus Repository Manager", "my.artifact.repo.net", "admin", "admin123")
    
    // file 
    credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
    

    【讨论】:

    • 凭证存储在 ~/.sbt/.credentials 下,此文件以“领域”布局格式化。在包含您提到的第二个内容的路径 ~/.sbt/0.13/plugins/credentials.sbt 下(当然是采用的路径)。
    • 但是您是否在 build.sbt 中指定了凭证文件的路径?我认为不会自动找到 .credentials 文件...
    猜你喜欢
    • 2015-07-22
    • 2021-05-17
    • 2010-11-24
    • 1970-01-01
    • 2013-05-16
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多