【问题标题】:Scala SBT set dockerRepository "Repository for publishing is not specified"Scala SBT设置dockerRepository“未指定发布存储库”
【发布时间】:2015-11-26 03:02:35
【问题描述】:

我正在尝试使用以下命令将 scala 构建发布到 docker 注册表:

./sbt "; set dockerRepository := Some(\"registryname/project\"); docker:publish"

我正在指定 dockerRepository,但是在运行命令时会抛出以下错误:

[error] You cannot push a "root" repository. Please rename your repository to <user>/<repo> (ex: <user>/example)
java.lang.RuntimeException: Repository for publishing is not specified.
[error] (all/*:publishConfiguration) Repository for publishing is not specified.
[error] (server/docker:publish) Nonzero exit value: 1
[error] (config/*:publishConfiguration) Repository for publishing is not specified.
[error] Total time: 63 s, completed 01/09/2015 10:48:04 AM

当我查看本地 docker 注册表时,我可以看到它编译了 docker 映像,但没有为 docker 注册表名称添加前缀:

docker images

REPOSITORY                                     TAG                                           IMAGE ID            CREATED             VIRTUAL SIZE
example                                        0.0.1    SNAPSHOT   a6eb8942aa9f        8 minutes ago       1.136 GB

所以它似乎不接受我在命令上设置的 dockerRepository 变量,这也在构建日志中:

[15:32:58][Step 4/5] [info] Loading project definition from /build/project
[15:33:01][Step 4/5] [info] Set current project to example (in build file:/build/)
[15:33:06][Step 4/5] [info] Defining {.}/*:dockerRepository
[15:33:06][Step 4/5] [info] The new value will be used by no settings or tasks.
[15:33:06][Step 4/5] [info] Reapplying settings...

【问题讨论】:

  • 你搞清楚了吗?
  • 它归结为变量范围 try : ./sbt "; set dockerRepository in ThisBuild := Some(\"registryname/project\"); docker:publish"

标签: scala docker sbt


【解决方案1】:

来自 Alex Laverty 的评论:

build.sbt:

dockerRepository in ThisBuild := Some("docker.io")

或在带有子模块的项目中:

lazy val server = (project in file("server"))
  .settings(dockerRepository := Some("docker.io"),
            dockerUsername := Some("pame"),
            ...)

然后:

sbt docker:publish

【讨论】:

    猜你喜欢
    • 2020-06-07
    • 2016-03-04
    • 2018-07-15
    • 2013-05-01
    • 2023-03-13
    • 2013-01-25
    • 2016-02-26
    • 2014-01-25
    • 1970-01-01
    相关资源
    最近更新 更多