Created
April 10, 2015 16:30
-
-
Save astral303/ba4595210c9645e493dc to your computer and use it in GitHub Desktop.
Running shell commands in Jenkins with sudo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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