我有一个SBT项目和一个CD管道,我想要的是执行以下一系列步骤:
现在,此时我还不想发布任何内容,因为我会将二进制文件提升到另一个环境以运行端到端测试。只有当它们成功完成时,我才想推送git标签并将我的artefact上传到远程artefactory存储库。我真正想要实现的是,能够首先运行sbt prepereRelease
之后我将升级到我的TEST环境,之后,如果一切正常,运行sbt doRelease
。所以我想在build.sbt中使用类似的东西:
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
setNextVersion,
commitNextVersion
)
commands += Command.command("prepareRelease")((state:State) => {
val newState = Command.process("release",state)
println("Release called from prepareRelease...")
newState
})
releaseProcess := Seq[ReleaseStep](
publishArtifacts,
setNextVersion,
commitNextVersion,
pushChanges
)
commands += Command.command("doRelease")((state:State) => {
val newState = Command.process("release",state)
println("Release called from doRelease...")
newState
})
我几乎觉得我必须定义两个自定义命令,每个命令都必须使用sbt-release
设置从releaseProcess
插件调用原始发布命令 - 这就是我要做的一点我知道该如何去做。遗憾的是,上述设置无效,因为releaseProcess
设置累积了这些步骤,您仍然可以立即执行所有步骤。
答案 0 :(得分:0)
您已将prepareRelease
和doRelease
定义为设置。这意味着设置的值仅在加载或重新加载构建时计算一次。此外,ReleaseStep
类型仅描述要作为发布过程的一部分执行的函数,并且不会自行执行任何操作。
看起来您正在使用sbt-release插件。在文档之后,您必须使用自定义步骤重新定义releaseProcess
密钥,并运行release
命令来执行它们。
答案 1 :(得分:0)
我最终实现它的方法是创建两个自定义命令并将releaseProcess
设置附加到state
对象,然后将其传递到release
插件:
// Defines the release process
releaseIgnoreUntrackedFiles := true
commands += Command.command("prepareRelease")((state: State) => {
println("Preparing release...")
val extracted = Project extract state
val customState = extracted.append(Seq(releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
runTest
)), state)
val newState = Command.process("release with-defaults", customState)
Command.process("dist", newState)
})
commands += Command.command("completeRelease")((state: State) => {
println("Completing release...")
val extracted = Project extract state
val customState = extracted.append(Seq(releaseProcess := Seq[ReleaseStep](
inquireVersions,
setNextVersion,
commitNextVersion,
pushChanges
)), state)
val newState = Command.process("release with-defaults", customState)
newState
})
所以我的管道做了类似于以下的事情:
sbt prepareRelease
此时我将二进制文件部署到我的TEST环境
如果一切正常,那么我会sbt completeRelease
最终curl
我的拉链成为nexus