Groovy web console

subscribe to the feed Subscribe
to this
site
terminal.run (via #groovywebconsole)
tweet this snippet Tweet
this
script

terminal.run

Published 3 months ago by RecuencoJones
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
// jenkins methods
def sh(command) {
  println "sh ${command}"
}

def bat(command) {
  println "bat ${command}"
}

def isLinux() {
  return true  // change to false to run as Windows
}

// parameters
def commands = [
  'ls',
  'moo'
]

// terminal.run code
def runner = {
  if (isLinux()) {
    sh it
  } else {
    bat it
  }
}

for (command in commands) {
  runner command
}