Jasmine Jasmine - 8 months ago 136
Groovy Question

jenkins - java.io.IOException: Cannot run program "groovy"

I have the following groovy script in a jenkins build

def myFractureNO = ${FRACTURE_NO};
def myBuildNumber = ${BUILD_NUMBER};
def projectXml = new XmlSlurper().parseText("curl http://sparkbuilder.corp.adobe.com:8080/job/FractureAUT/api/xml".execute().text);
projectXml.build.each {
if(it.number < myBuildNumber)
def jobXml = new XmlSlurper().parseText(("curl http://sparkbuilder.corp.adobe.com:8080/job/FractureAUT/" + it.number + "/api/xml").execute().text);

if(1) {
def myparams = jobXml.getAction(hudson.model.ParametersAction.class);
for( p in myparams ) {
if (p.name.toString == "FRACTURE_NO") {
if (p.value.toString() == "$myFractureNO") {
println p.value.toString();

I get an error saying

java.io.IOException: Cannot run program "groovy"

when jenkins tries to run this script on a Jenkins slave. How do I fix this?

Now I get the following error when trying to execute the script as a system script

groovy.lang.MissingMethodException: No signature of method: Script1.$() is applicable for argument types: (Script1$_run_closure1) values [Script1$_run_closure1@5e38bed4]
Possible solutions: is(java.lang.Object), run(), run(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;)
at Script1.run(Script1.groovy:1)


The following is not valid groovy:

def myFractureNO = ${FRACTURE_NO};
def myBuildNumber = ${BUILD_NUMBER};

I'm guessing you're trying to get some variables from the environment. See this related question: http://stackoverflow.com/a/26428580/172599