title: Gradle exec commandLine does not work as expected
body: <p>I'm currently working on a Gradle project in OSX
  My function in a .gradle file looks like this</p>
  
  <pre><code>ext.MyFunction = {
  
       def fastlaneCommand = [
               'fastlane',
               '-version'
       ]
  
       def stdout = new ByteArrayOutputStream()
  
       exec {
           ignoreExitValue true
           standardOutput stdout
           workingDir PathsModel.instance.GetDeployerRoot()
           commandLine fastlaneCommand
           LOG.WARN("YOUR CLI COMMAND: " + commandLine)
       }
       println "Output:\n$stdout"
  }
  </code></pre>
  
  <p>And then in 'build.gradle'</p>
  
  <pre><code>task jenkins_deploy() {
      doFirst {
          MyFunction()
      }
  }
  </code></pre>
  
  <p>When it comes time for commandLine to be executed
  This outputs:</p>
  
  <pre><code>W A R N I N G:  YOUR CLI COMMAND: [fastlane, -version]
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':jenkins_deploy'.
  &gt; A problem occurred starting process 'command 'fastlane''
  </code></pre>
  
  <p>I know for a fact that fastlane is in my path as '$HOME/.fastlane/bin' which is where the executable is located. And if I simply open Terminal and type </p>
  
  <blockquote>
    <p>'fastlane -version'</p>
  </blockquote>
  
  <p>from any directory, fastlane tools start-up and do what they're supposed to be doing.</p>
  
  <p>I suppose my question is:
  What are the possible differences between me opening a terminal and inputting the command manually, and me asking Gradle to do the exact same thing using 'exec'? 
  Am I misunderstanding what 'exec' and 'commandLine' actually do?</p>
  
  <p>Some info on 'fastlane' is that it's using Ruby, which i don't know a lot about. This may prove relevant.</p>
  
  <p>EDIT: I <em>have</em> attempted 'version' the 2nd element in the fastlaneCommand array, as both 'version' and '-version' </p>
  
  <p>EDIT 2 (ACTUAL SOLUTION): Although the marked answer below is a definite workaround, the solution <a href="https://stackoverflow.com/questions/31403573/specify-path-environment-does-not-work-when-running-gradle-exec" title="here">Actual solution</a> has the full reason as to why this happens and why it works.</p>