Skip to content

Instantly share code, notes, and snippets.

@astral303
Created April 10, 2015 16:30
Show Gist options
  • Save astral303/ba4595210c9645e493dc to your computer and use it in GitHub Desktop.
Save astral303/ba4595210c9645e493dc to your computer and use it in GitHub Desktop.
Running shell commands in Jenkins with sudo
// Use unbuffer to avoid sudo complaining about no tty requirement
def cmd = ["/bin/bash", "-c", "unbuffer sudo service sshd status"]
def proc = cmd.execute()
def outputStream = new StringBuffer()
def errStream = new StringBuffer()
proc.waitForProcessOutput(outputStream, errStream)
println(outputStream.toString())
println(errStream.toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment