Automation: How to assign images tag which depends on build number?

Hi, 


How can I assign container's tag which depends on something which is unique to current build  (e.g build number): 
According to https://www.jetbrains.com/help/space/automation-environment-variables.html, it should be easy:

JB_SPACE_EXECUTION_NUMBER executionNumber(): String Current build number. For example, you can use it to generate application version number. Learn more

And an example via 'Learn more' link:

kotlinScript { api -> println("Build #" + System.getenv("JB_SPACE_EXECUTION_NUMBER"))


However it doesn't work for me:

push("mycompany.registry.jetbrains.space/p/xxx/containers/server") {
tag = "0.${System.getenv("JB_SPACE_EXECUTION_NUMBER")}"
}


I got container with tag  "0.null"

Same if I tried to use space.system.execution_number.

1
1 comment

Yeah, it is a bit annoying.  It seems that automation variables are properly set only within the `kotlinScript` stanza.  They are available within `shellScript` as environment variables for the specified `interpreter` (for example. `/bin/bash`), but they are not available for `.space.kts`.

Reported it as a bug:

https://youtrack.jetbrains.com/issue/SPACE-10790 

I am afraid that until it is fixed, it is impossible to assign a docker tag, which is not hardcoded in `.space.kts`.

EDIT: fix typo

0

Please sign in to leave a comment.