JetBrains Space automation script

272 views Asked by At

I try to solve the following issue:

job("Docker | deploy") {
    docker {
        build {
            context = "docker"
            file = "./docker/Dockerfile"
            labels["vendor"] = "mycompany"
            args["HTTP_PROXY"] = "http://10.20.30.1:123"
        }

        push("registry.com") {
            versionOne = Params("version-one")
            versionTwo = Params("version-two")
            
            tag = "${'$'}versionOne-${'$'}versionTwo"
        }
    }
}

Within the push step, the tag should be combined of versionOne and versionTwo dynamically, but I don't figured it out how to achieve this.

Does someone know how to use variables dynamically in a space automation script?

2

There are 2 answers

0
Joffrey On

The docker DSL is now deprecated. Instead, use the dockerBuildPush DSL in a host step (instead of a docker/kaniko step).

Also, for regular project parameters (not secrets), you can use the {{ project:<param> }} template syntax instead of going through environment variables:

job("Docker | deploy") {    
    host {
        dockerBuildPush {
            context = "docker"
            tags {
                +"registry.com/image:{{ project:version-one }}-{{ project:version-two }}"
            }
        }
    }
}
0
Mikhail Kadysev On

The correct way to do it below:

job("Docker | deploy") {
    env["VERSION_ONE"] = Params("version-one")
    env["VERSION_TWO"] = Params("version-two")

    docker {
        build {
            context = "docker"
            file = "./docker/Dockerfile"
            labels["vendor"] = "mycompany"
            args["HTTP_PROXY"] = "http://10.20.30.1:123"
        }

        push("registry.com") {
            tags("${'$'}VERSION_ONE-${'$'}VERSION_TWO")
        }
    }
}