我将sbt-release
插件用于几个项目。我使用的一个步骤是docker:publish
的{{1}}将映像推送到Docker集线器。
sbt-native-packager
依靠sbt-native-packager
设置来决定是否更新dockerUpdateLatest
标签。默认值为latest
,如果为false
,它将更新true
。
对于一个在根目录下没有子项目的项目,我可以使用自定义latest
来更改该设置,具体取决于我是否发布ReleaseStep
,即我不想如果版本以SNAPSHOT
结尾,请更新latest
标签。
SNAPSHOT
以上内容适用于该项目。
对于另一个项目,根目录下聚合了多个项目。我想做类似的事情
lazy val setDockerReleaseSettings = ReleaseStep(action = oldState => {
// dockerUpdateLatest is set to true if the version is not a SNAPSHOT
val extracted = Project.extract(oldState)
val v = extracted.get(Keys.version)
val snap = v.endsWith("SNAPSHOT")
if (!snap) extracted
.appendWithSession(Seq(dockerUpdateLatest := true), oldState)
else oldState
})
但是它似乎不起作用。我也尝试了lazy val setDockerReleaseSettings = ReleaseStep(action = oldState => {
// dockerUpdateLatest is set to true if the version is not a SNAPSHOT
val extracted = Project.extract(oldState)
val v = extracted.get(Keys.version)
val snap = v.endsWith("SNAPSHOT")
if (!snap) extracted
.appendWithSession(Seq(dockerUpdateLatest in api := true, dockerUpdateLatest in portal := true), oldState)
else oldState
})
和dockerUpdateLatest in Global
无济于事。有任何想法如何在这些子项目中更改dockerUpdateLatest in root
?
答案 0 :(得分:0)
可以用set every dockerUpdateLatest := true
解决。我这样做了一个自定义的ReleaseStep
lazy val createSetDockerUpdateLatestCommand = ReleaseStep(action = state => {
// dockerUpdateLatest is set to true if the version is not a SNAPSHOT
val snap = Project.extract(state).get(Keys.version).endsWith("SNAPSHOT")
val setDockerUpdateLatest = if (!snap)
Command.command("setDockerUpdateLatest") {
"set every dockerUpdateLatest := true" ::
_
}
else
Command.command("setDockerUpdateLatest") {
"" ::
_
}
state.copy(definedCommands = state.definedCommands :+ setDockerUpdateLatest)
})
然后我运行setDockerUpdateLatest