Skip to content

Instantly share code, notes, and snippets.

@katta
Created April 26, 2013 06:09
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save katta/5465317 to your computer and use it in GitHub Desktop.
Save katta/5465317 to your computer and use it in GitHub Desktop.
Groovy shell command
def command = "git --version"
def proc = command.execute()
proc.waitFor()
println "Process exit code: ${proc.exitValue()}"
println "Std Err: ${proc.err.text}"
println "Std Out: ${proc.in.text}"
@roscrazy
Copy link

thank for the commands

@AssiNET
Copy link

AssiNET commented Sep 14, 2018

Thanks for the script 👍

@vishnujanardhanan
Copy link

thanks for the script again :)

@marslo
Copy link

marslo commented Apr 23, 2021

with git working dir:

String command = "git log -1"
def proc = command.execute( null, new File("/path/to/folder") )
proc.waitFor()              

println """
  ${proc.err.text ?: ''}
  ${proc.in.text ?: ''}
  Process exit code: ${proc.exitValue()}
"""

or with system environment

List env = System.getenv().collect { k, v -> "${k}=${v}" }
String command = "git log -1"
def proc = command.execute( env, new File("/path/to/folder") )
proc.waitFor()  

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