Java Code Examples for hudson.slaves.EnvironmentVariablesNodeProperty#getEnvVars()
The following examples show how to use
hudson.slaves.EnvironmentVariablesNodeProperty#getEnvVars() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepairnatorPostBuild.java From repairnator with MIT License | 6 votes |
public void createGlobalEnvironmentVariables(String key, String value){ Jenkins instance = Jenkins.getInstance(); DescribableList<NodeProperty<?>, NodePropertyDescriptor> globalNodeProperties = instance.getGlobalNodeProperties(); List<EnvironmentVariablesNodeProperty> envVarsNodePropertyList = globalNodeProperties.getAll(EnvironmentVariablesNodeProperty.class); EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = null; EnvVars 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(); } envVars.put(key, value); try { instance.save(); } catch(Exception e) { System.out.println("Failed to create env variable"); } }
Example 2
Source File: AbstractKubernetesPipelineTest.java From kubernetes-plugin with Apache License 2.0 | 6 votes |
@Before public void configureCloud() throws Exception { cloud = setupCloud(this, name); createSecret(cloud.connect(), cloud.getNamespace()); cloud.getTemplates().clear(); cloud.addTemplate(buildBusyboxTemplate("busybox")); setupHost(); r.jenkins.clouds.add(cloud); DescribableList<NodeProperty<?>, NodePropertyDescriptor> list = r.jenkins.getGlobalNodeProperties(); EnvironmentVariablesNodeProperty newEnvVarsNodeProperty = new hudson.slaves.EnvironmentVariablesNodeProperty(); list.add(newEnvVarsNodeProperty); EnvVars envVars = newEnvVarsNodeProperty.getEnvVars(); envVars.put("GLOBAL", "GLOBAL"); envVars.put("JAVA_HOME_X", "java-home-x"); r.jenkins.save(); }
Example 3
Source File: EnvInterpolationTest.java From appcenter-plugin with MIT License | 5 votes |
@Before public void setUp() throws IOException { freeStyleProject = jenkinsRule.createFreeStyleProject(); freeStyleProject.getBuildersList().add(TestUtil.createFile("three/days/xiola.ipa")); freeStyleProject.getBuildersList().add(TestUtil.createFile("three/days/blue.zip")); freeStyleProject.getBuildersList().add(TestUtil.createFile("three/days/linear-notes.md", "I prepared the room tonight with Christmas lights.")); final EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty(); final EnvVars envVars = prop.getEnvVars(); envVars.put("OWNER_NAME", "janes-addiction"); envVars.put("APP_NAME", "ritual-de-lo-habitual"); envVars.put("PATH_TO_APP", "three/days/xiola.ipa"); envVars.put("BUILD_VERSION", "1.2.3"); envVars.put("PATH_TO_DEBUG_SYMBOLS", "three/days/blue.zip"); envVars.put("DISTRIBUTION_GROUPS", "casey, niccoli"); envVars.put("RELEASE_NOTES", "I miss you my dear Xiola"); envVars.put("PATH_TO_RELEASE_NOTES", "three/days/linear-notes.md"); jenkinsRule.jenkins.getGlobalNodeProperties().add(prop); final AppCenterRecorder appCenterRecorder = new AppCenterRecorder( "at-this-moment-you-should-be-with-us", "${OWNER_NAME}", "${APP_NAME}", "${PATH_TO_APP}", "${DISTRIBUTION_GROUPS}" ); appCenterRecorder.setBuildVersion("${BUILD_VERSION}"); appCenterRecorder.setPathToDebugSymbols("${PATH_TO_DEBUG_SYMBOLS}"); appCenterRecorder.setReleaseNotes("${RELEASE_NOTES}"); appCenterRecorder.setPathToReleaseNotes("${PATH_TO_RELEASE_NOTES}"); appCenterRecorder.setBaseUrl(mockWebServer.url("/").toString()); freeStyleProject.getPublishersList().add(appCenterRecorder); }
Example 4
Source File: TestUtils.java From phabricator-jenkins-plugin with MIT License | 4 votes |
public static void setEnvironmentVariables(JenkinsRule j, Map<String, String> params) throws IOException { EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty(); EnvVars envVars = prop.getEnvVars(); envVars.putAll(params); j.jenkins.getGlobalNodeProperties().add(prop); }