I have a Jetbrains Space Automation worker that builds a Docker image of my project and pushes it to Space. It should tag each built image with the current date, but instead it keeps tagging each build with the date that the build script was last compiled. How can I access the current date inside the build script?
job("Build Backend Production") {
startOn {
gitPush {
anyBranchMatching {
+"main"
}
}
}
host("Build Backend Docker Image") {
dockerBuildPush {
file = "my-backend/Dockerfile"
val spaceRepo = "<company>.registry.jetbrains.space/p/main/docker-images/my-backend"
val version = LocalDate.now().toString().replace("-", "")
tags {
+"$spaceRepo:release.1.0.${"$"}JB_SPACE_EXECUTION_NUMBER"
+"$spaceRepo:release.$version"
}
}
}
}
In the build logs, I have lines like these. The execution number increments each time, but the date is always 20240502 (the date I last updated the .space.kts
-file):
#20 writing image sha256:9ccef49a67320db7677d1525b638c25177874489c302bcdcaec587e4a315fd76 done
#20 naming to <company>.registry.jetbrains.space/p/main/docker-images/my-backend:release.1.0.7 done
#20 naming to <company>.registry.jetbrains.space/p/main/docker-images/my-backend:release.20240502 done