Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active September 12, 2021 07:44
Show Gist options
  • Save turboBasic/7e89b897ad86cd45ac3e7edb23ea4eff to your computer and use it in GitHub Desktop.
Save turboBasic/7e89b897ad86cd45ac3e7edb23ea4eff to your computer and use it in GitHub Desktop.
Execute complex bash command in Jenkins script console #jenkins #groovy #shell
String DIR = '/data/jenkins/workspace/UISW-C-UI/Daily/c-daily-build'
void executeInBash(String bashCommand) {
java.lang.Process process = ['/bin/bash', '-c', bashCommand].execute()
process.waitFor()
println process.getText()
}
//////
[
"ls -AlF $DIR",
"sudo ps auxww | grep -P 'jenkins|ssh' && free",
]
.each {
executeInBash it
}
null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment