I have an issue that I have been working on for about two days straight with no luck. I have two task, package and deploy that both change depending on the environment being deployed to. I am using the sbt-native-packager plugin for packaging and the sbt-deploy-ssh for deployment.
我有一个问题,我已经连续两天工作,没有运气。我有两个任务,包和部署,它们都会根据所部署的环境而改变。我使用sbt-native-packager插件进行打包,使用sbt-deploy-ssh进行部署。
My package task gets called by an inputTask like so: bundle "env"
我的包任务被inputTask调用,如:bundle“env”
lazy val setEnv : Def.Initialize[InputTask[String]] = Def.inputTask {
sbt.Def.spaceDelimited("<arg>").parsed(0)
}
lazy val configure : Def.Initialize[InputTask[String]] = Def.inputTask {
val env = setEnv.evaluated
writeConfig(env)
env
}
lazy val bundle = inputKey[Unit]("bundles project for specific env")
bundle := configure.parsed.flatMap { _ =>
(packageBin in config("universal")).taskValue
}.value
My deploy task gets called by an inputTask like so: deployTo "env"
我的部署任务由inputTask调用,如下所示:deployTo“env”
val deployTo = inputKey[Unit]("Deploys to specific env")
deployTo := Def.inputTaskDyn {
val args = sbt.Def.spaceDelimited("<args>").parsed
deployWithDynamicServers(getServers(args(0)))
}.evaluated
def deployWithDynamicServers(servers: Seq[String]) = Def.taskDyn {
deploySsh.toTaks(" " + servers.mkString(" "))
}
I can run both of these individually, but I want the deploy task to be dependent on the package task. What I want to be able to do is run deployTo and have the supplied env passed to the package task as well.
我可以单独运行这两个,但我希望部署任务依赖于包任务。我想要做的是运行deployTo并将提供的env传递给包任务。
So far I haven't had much luck because I keep getting "Illegal Dynamic reference errors" even though both the package and deploy task are Def.inputTaksDyn
到目前为止,我没有太多运气因为我不断得到“非法动态参考错误”,即使包和部署任务都是Def.inputTaksDyn
1 个解决方案
#1
您的案例在此处描述。
Just add your env to the deployConfigs
只需将您的env添加到deployConfigs即可
deployConfigs ++= Seq(
ServerConfig("env", "169.254.0.2")
)
add the artifact to the deployArtifacts
将工件添加到deployArtifacts
deployArtifacts ++= Seq(
ArtifactSSH((packageBin in config("universal")).value, "/tmp/")
)
and start deploy with deploySsh
.
并使用deploySsh开始部署。
deploySsh yourServerName1 yourServerName2 ...
#1
您的案例在此处描述。
Just add your env to the deployConfigs
只需将您的env添加到deployConfigs即可
deployConfigs ++= Seq(
ServerConfig("env", "169.254.0.2")
)
add the artifact to the deployArtifacts
将工件添加到deployArtifacts
deployArtifacts ++= Seq(
ArtifactSSH((packageBin in config("universal")).value, "/tmp/")
)
and start deploy with deploySsh
.
并使用deploySsh开始部署。
deploySsh yourServerName1 yourServerName2 ...