Jenkins - Java. Io. Ioexception: Cannot Run Program "Groovy"

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 ".execute().text);
projectXml.build.each {
  if(it.number < myBuildNumber)
  {
      def jobXml = new XmlSlurper().parseText(("curl " + 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)
3

1 Answer

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.