Last active
December 16, 2015 00:49
-
-
Save thomasbiddle/5350078 to your computer and use it in GitHub Desktop.
Grabbing an environment variable from Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming environment is an EnvVars object, and mergeOptions is an arbitrary object that, when I call getMergeOptions(), returns the branch I'm merging with - Which can either be a string - or an environment variable, $some_var | |
String mergeTarget = ""; | |
if ( environment.get(mergeOptions.getMergeTarget()) != null ) { | |
mergeTarget = environment.get(mergeOptions.getMergeTarget().substring(1)); | |
} else { | |
mergeTarget = mergeOptions.getMergeTarget(); | |
} | |
vs... | |
mergeTarget = environment.expand(mergeOptions.getMergeTarget()); | |
// I'm assuming the second one is the correct way to do it here :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment