I have a groovy script that pulls the maven version from the project pom
and sets and environment variable (included below for anyone that wants it).

In the job section for executing a "System Groovy Script" I can insert the
code directly or reference what seems to be an arbitrary path to the groovy
script on the file system.

However, I'd like to manage the script file more centrally on Jenkins and
be able to edit content from the jenkins UI as opposed to manually doing it
on the system.  I looked at the Config File Provider Plugin but it I don't
know how to reference it so it will run as a "System Groovy Script" because
it stores the content in an XML format.

Does anyone know how to best accomplish this?

Here is the script:

import hudson.model.*;
import hudson.util.*;

def mavenVer;
def thr = Thread.currentThread();
def currentBuild = thr?.executable;
def newParamAction;

try {
    mavenVer =
currentBuild.getParent().getModules().toArray()[0].getVersion();
} catch (Throwable t){
    mavenVer = "UNKNOWN";
}
newParamAction = new hudson.model.ParametersAction(new
hudson.model.StringParameterValue("MAVEN_VERSION", mavenVer));
currentBuild.addAction(newParamAction);


-- 
Jeff Vincent
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to