ZekeJackhammer
ZekeJackhammer

Reputation: 137

Trying to undersand how I can pass arguments from gradle to my shell script?

I'm trying to pass command line arguments to my shell script through a gradle task myconfiguration is like this below.

task dosomething(type:Exec) {
  workingDir 'dir'
  executable 'sh'
  args '-c','source dosomething.sh $arg'
}

And I'm trying to pass it by doing the the following command in the terminal:

$ gradle dosomething -Parg=foo

And it does not work am I doing something wrong?

Upvotes: 4

Views: 3857

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123900

Groovy only performs String interpolation for double-quoted Strings. (That's one of the reasons why I use double quotes by default.) Try:

...
args "-c", "source dosomething.sh $arg"

Upvotes: 9

Related Questions