How to use global variable in pipeline DSL?

Hello,

We have defined some Environment variables, under “Global Properties” (screenshot added).

We now want to use the “pipeline_repo_ssh_url_d” variable in a job, defined as code, stored in a file in our repo.

The job definition is:

def envVar = getBinding().getVariables()['pipeline_repo_ssh_url_d']

pipelineJob("globalVariable-test") {
    description """
test job
    """
    parameters {
        stringParam("meta", "", "${envVar}")
    }
    properties {
        disableConcurrentBuilds()
    }
    environmentVariables {
        keepSystemVariables(true)
    }
    logRotator {
        daysToKeep(30)
        numToKeep(100)
    }
    quietPeriod(0)
    definition {
        cpsScm {
            lightweight(false)
            scm {
                git {
                    remote {
                        url("${envVar}")
                        credentials('github.geo.de-ssh')
                        refspec('$releaseBranch refs/heads/*:refs/remotes/origin/*')
                    }
                    extensions {
                        cloneOptions {
                            honorRefspec(true)
                        }
                        gitLFSPull()
                        pruneStaleBranch()
                    }
                    branches('$releaseBranch')
                }
            }
            scriptPath('JenkinsfileRelease')
        }
    }
}

I found Jenkins Job DSL Plugin , so that’s why I have this part added:

environmentVariables {
    keepSystemVariables(true)
}

but it does not explain how to actually use a global variable. I also tried with:

remote { url("${pipeline_repo_ssh_url_d}") credentials('github.geo.de-ssh') refspec('$releaseBranch refs/heads/*:refs/remotes/origin/*') }

and both of these return nothing. When the job configuration is opened, I see just an empty field (screenshot added).

How do I actually call that variable?

Thank you!

url(‘’‘$\u007Bpipeline_repo_ssh_url_d\u007D’‘’) - unicode representation of curly brackets; the job configuration sees this string; then when the build runs, it is able to interpret it and retrieve the variable value;