Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
JENKINS-24735 - Add support for build parameters in Subversion URLs
* Extract SVNUrl variable expansion into a utility and use that acrosss all classes that require it.
- Loading branch information
1 parent
8e84f51
commit c1c458c
Showing
3 changed files
with
62 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package jenkins.plugins.svnmerge; | ||
|
||
import hudson.EnvVars; | ||
import hudson.model.Computer; | ||
import hudson.model.Job; | ||
import hudson.scm.SubversionSCM.ModuleLocation; | ||
import hudson.slaves.EnvironmentVariablesNodeProperty; | ||
import hudson.slaves.NodeProperty; | ||
|
||
import java.io.IOException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class Utility { | ||
|
||
|
||
/** | ||
* Expands the system variables, the node environment variables and the project parameters | ||
*/ | ||
public static ModuleLocation getExpandedLocation(ModuleLocation ml, Job<?,?> project) { | ||
ModuleLocation location= ml.getExpandedLocation(project); | ||
// expand system variables | ||
Computer c = Computer.currentComputer(); | ||
if (c != null) { | ||
try { | ||
// JVM vars | ||
EnvVars cEnv = c.getEnvironment(); | ||
location = location.getExpandedLocation(cEnv); | ||
// node vars | ||
for (NodeProperty<?> nodeProp : c.getNode().getNodeProperties()) { | ||
if (nodeProp instanceof EnvironmentVariablesNodeProperty) { | ||
EnvVars nodeEnvVars = ((EnvironmentVariablesNodeProperty) nodeProp) | ||
.getEnvVars(); | ||
location = location | ||
.getExpandedLocation(nodeEnvVars); | ||
|
||
} | ||
} | ||
} catch (IOException e) { | ||
LOGGER.log(Level.WARNING, "Failed to get computer environment", | ||
e); | ||
} catch (InterruptedException e) { | ||
LOGGER.log(Level.WARNING, "Failed to get computer environment", | ||
e); | ||
|
||
} | ||
} | ||
// expand project variables | ||
if(project!=null){ | ||
location = location.getExpandedLocation(project); | ||
} | ||
return location; | ||
} | ||
|
||
private static final Logger LOGGER = Logger.getLogger(Utility.class.getName()); | ||
} |