-
Patch
-
Resolution: Unresolved
-
Major
-
None
-
any
I had the need to be able to use the node properties env vars in the plugin .
So for example we needed to build the same project on a different hardware and OS.
Like Solaris SPARC, AIX, HPUX, Windows and so on.
So in the node properties env vars we set variables for identifying which is the computer and the OS version/platform and others.
Those environment variables we needed to use in the plugin so we can know which project was build successful or failed or any
other problems.
Here is the code changes I made to work as I needed:
The changes was only in class
/svn-tag-1.12-sources/hudson/plugins/svn_tag/SvnTagPlugin.java
I added a methods:
// Patched for env vars
/**
- Returns the environment variables set for a node/slave. So you can use
- them, as are in your environment
- @param envVars
- @return
*/
public static EnvVars getEnvVars() {
Node node = Computer.currentComputer().getNode();
DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties = node
.getNodeProperties();
if (Computer.currentComputer() instanceof MasterComputer)
{ Hudson instance = Hudson.getInstance(); nodeProperties = instance.getGlobalNodeProperties(); } // System.out.println(".getEnvVars()Computer.currentComputer() = "Computer.currentComputer()
// "nodeProperties = "+nodeProperties);
return getEnvVars(nodeProperties);
}
/**
- @param nodeProperties
*/
public static EnvVars getEnvVars(
DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties) {
Iterator<NodeProperty<?>> iterator = nodeProperties.iterator();
while (iterator.hasNext()) {
NodeProperty<?> next = iterator.next();
// System.out.println(".getEnvVars()Computer.currentComputer() = "
// + Computer.currentComputer() + " next = " + next);
if (next instanceof EnvironmentVariablesNodeProperty)
}
return null;
}
/**
- @return
*/
public static EnvVars getGlobalEnvVars() { Hudson instance = Hudson.getInstance(); DescribableList<NodeProperty<?>, NodePropertyDescriptor> nodeProperties = instance .getGlobalNodeProperties(); return getEnvVars(nodeProperties); }
// ~Patched for env vars
I changed the method so the validation to work:
static String evalGroovyExpression(Map<String, String> env, String evalText,
List locationPathElements) {
// Patched for env vars
if (env == null || env.isEmpty()) {// validation faze
env = new HashMap<String, String>();
EnvVars objNodeEnvVars = getGlobalEnvVars();
if (objNodeEnvVars != null)
}
evalText = Util.replaceMacro(evalText, env);
// ~Patched for env vars
.............................................
.............................................
I changed the method perform in :
public static boolean perform(AbstractBuild abstractBuild, Launcher launcher,
BuildListener buildListener, String tagBaseURLStr, String tagComment,
String tagMkdirComment, String tagDeleteComment) {
......................
......................
SubversionSCM scm = SubversionSCM.class.cast(rootProject.getScm());
env = abstractBuild.getEnvVars();
// Patched for env vars
EnvVars objNodeEnvVars = getEnvVars();
if (objNodeEnvVars != null)
// ~Patched for env vars
Of course the dots is the current source code that I left unchaged and you have it.