Skip to content

Instantly share code, notes, and snippets.

@lyuboraykov
Created August 8, 2014 11:19
Show Gist options
  • Save lyuboraykov/8deae849e4812669793a to your computer and use it in GitHub Desktop.
Save lyuboraykov/8deae849e4812669793a to your computer and use it in GitHub Desktop.
Execute shell command with piping in groovy
def command = 'ls | grep foo'
def output = ['bash', '-c', command].execute().in.text
Copy link

ghost commented Feb 24, 2022

How to call groovy variable inside shell?

def var="test"
def command = '''
ls -l
echo $var
'''
def proc = ['bash', '-c', command].execute()

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