Skip to content

Instantly share code, notes, and snippets.

@adampats
Created May 18, 2016 22:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adampats/e682c61fb425a200453607a663980af4 to your computer and use it in GitHub Desktop.
Save adampats/e682c61fb425a200453607a663980af4 to your computer and use it in GitHub Desktop.
Jenkins groovy script to execute shell command
def cmd = 'hostname'
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println sout
@RakeshNagarajan
Copy link

RakeshNagarajan commented May 29, 2019

Thanks. But the below command is not working.

def cmd = 'find ./ -mindepth 2 -type f | cut -d/ -f2 | sort | uniq -c | sort -nr'
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println sout

Also wildcard is not working. is there any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment