Groovy for Hudson console

Hudson continuous integration server has a console which is good for testing scripts and access to commands that your Hudson jobs need.

The hudson console only let’s you run Groovy script. To run commands on the machine, Groovy has the method "string".execute(). So now I can use this snippet to test versions of Ruby, JRuby, etc:

def commands = ["ruby --version", "gem environment", "which ruby", "which gem", "jruby --version"]


def run(cmd) {
  //def proc = commands[1].execute()
  def proc = cmd.execute()

  // Obtain status and output
  println "return code: ${ proc.exitValue()}"
  println "stderr: ${proc.err.text}"
  println "stdout: ${}" // *out* from the external program is *in* for groovy


Example borrowed from and shrinkwrapped from

Comments are closed.