i would like to get data like version
, packageName in Docker
and such somehow. I need it for my CI to tag docker image for future use.
So is there any possibility to get such values like with maven mvn --batch-mode -f pom.xml help:evaluate -Dexpression=project.version
.
Thanks for help in advance.
So my build.sbt contains several projects and right now i am trying to use sbt projects
,sbt inspect
from sbt inspect build but no luck so far.
I managed to get key values from project but now i have problem with packageName in Docker
. i make it with: sbt [project_name]/[key]
but for packageName in Docker
i got:
sbt projectName/packageName in Docker
[error] Not a valid command: in
[error] Expected 'info'
[error] Not a valid project ID: in
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: in
[error] in
[error] ^
This is part of build.sbt:
lazy val `name` = project
.in(file("name"))
.dependsOn(`name-dep`)
.settings(defaults)
.settings(
packageName in Docker := "project/name",
version := "3.1.0-SNAPSHOT",
dockerExposedPorts := Seq(8080),
dockerCommands ++= Seq(
Cmd("ENTRYPOINT",
s"bin/${executableScriptName.value}",
"-l", "tcp://0.0.0.0:8081",
"-e", "${EXTERNAL_URL}",
"-c", "${CONNECTOR_URL}")
),
For version i use:
sbt name/version
[info] Loading project definition from /home/jenkins/.jenkins/workspace/project
[info] Set current project to root (in build file:/home/jenkins/.jenkins/workspace/)
[info] 3.1.0-SNAPSHOT
but i have problems with packageName in Docker
so i managed to get those values with:
# sbt -Dsbt.log.noformat=true name/packageName | sed -n 3p | cut -d " " -f 2
name
it dosen't display whole packageName ( without project/
) but as i know that this is a constant i will hardcode it in CI script.
and
# sbt -Dsbt.log.noformat=true name/version | sed -n 3p | cut -d " " -f 2
3.1.0-SNAPSHOT
if anyone has better idea please share with me.
Be advised that sbt i using ASCII codes to colorize the output so tu use it like in my solution you have to run sbt with -Dsbt.log.noformat=true
otherwise your CI can complain about ENV's values and you wont see this.
My suggestion would be to use sbt-native-packager.
Also this packager got Docker Plugin
Which gives you out of box docker image on sbt build with version number. We are using sbt-package-manager in all our modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With