aboutsummaryrefslogtreecommitdiffstats
path: root/tools/moon_jenkins/setenv.groovy
blob: ab2dc13724bb7c8a064dc3c0bb9be5ab8e1b1ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!groovy

import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*

instance = Jenkins.getInstance()
globalNodeProperties = instance.getGlobalNodeProperties()

envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)

newEnvVarsNodeProperty = null
envVars = null

if (envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0) {
    newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty();
    globalNodeProperties.add(newEnvVarsNodeProperty)
    envVars = newEnvVarsNodeProperty.getEnvVars()
} else {
    envVars = envVarsNodePropertyList.get(0).getEnvVars()
}

http_proxy = System.getenv()['http_proxy']
https_proxy = System.getenv()['https_proxy']

if (http_proxy) {
  envVars.put("http_proxy", System.getenv()['http_proxy'])
}
if (https_proxy) {
  envVars.put("https_proxy", System.getenv()['https_proxy'])
}

instance.save()