JetBrains Space Help

Generate Artifact Version

To generate an artifact version, use provided Automation parameters, e.g. a job run ID, a branch or project name, and so on.

For example, you want to generate a Docker container tag based on the current branch name and the job run number like version-0.123-mybranch:

job("Build and push image") { kaniko { beforeBuildScript { // Create an env variable BRANCH, // use env var to get full branch name, // leave only the branch name without the 'refs/heads/' path content = """ export BRANCH=${'$'}(echo ${'$'}JB_SPACE_GIT_BRANCH | cut -d'/' -f 3) """ } build { context = "docker" dockerfile = "./docker/Dockerfile" } push("") { // Use the BRANCH and JB_SPACE_EXECUTION_NUMBER env vars tags { +"version-0.\$JB_SPACE_EXECUTION_NUMBER-\$BRANCH" } } } }
Last modified: 09 August 2023