user6826691
user6826691

Reputation: 2011

How to pass global system env variables to jenkins dsl job?

I have set a global jenkins env variable but for some reason my build is not picking system env variable. There is no error, but its not executing the if condition.

Pls point me where i'm wrong and how to use already set global system env variables in jenkins dsl.

Env variable set :

root@amp-jenkins-0:/var/jenkins_home/jobs# cat generator-job/builds/11/injectedEnvVars.txt | grep eks
kubernetes_cluster_name=xx-xxx

Upvotes: 0

Views: 568

Answers (2)

user6826691
user6826691

Reputation: 2011

This worked for me

getBinding().getVariables()['kubernetes_cluster_name']

Upvotes: 0

Dmitriy Tarasevich
Dmitriy Tarasevich

Reputation: 1242

This should work

job('example') {
  environmentVariables {
    keepSystemVariables(true)
  }
}

Description is here

Upvotes: 1

Related Questions