title: Gradle exec task returns non-zero exit value and fails the build but I want to not fail and instead perform another task
body: <p>I have an exec task set up in a pretty default way, something like:</p>
  
  <pre><code>task myTask(type:Exec) {
  
      workingDir '.'
  
      commandLine './myscript.sh'
  
      doLast {
          if(execResult == 0) {
             //one thing
          } else {
             //another thing
          }
      }
  }
  </code></pre>
  
  <p>But unfortunately it never executes the doLast block when an error is thrown by the script. Instead it skips that and fails the entire build with </p>
  
  <blockquote>
    <p>Execution failed for task ':project:myTask'.
    Process 'command './myscript.sh'' finished with non-zero exit value 1"</p>
  </blockquote>
  
  <p>That's useless to me. The whole idea of myscript.sh finishing with a non-zero exit value is so I can then execute some code in response to it. What do I need to do to not fail the build but capture the result and perform an action in response? Thanks for the help!</p>