title: Jenkins on Ubuntu, gradle fails on premission denied
body: <p>I have a simple JenkinsFile that I'm running through Jenkins v2.121.3 on Ubuntu v18.04.1 LTS:</p>
  
  <pre><code>pipeline {
    agent {
      // Run on a build agent where we have the Android SDK installed
      label 'android'
    }
    stages {
      stage('Compile') {
        steps {
          // Compile the app and its dependencies
          sh './gradlew compileProdDebugSources'
        }
      }
    }
  }
  </code></pre>
  
  <p>When I run my Jenkins job, it fails when running <code>+ ./gradlew compileProdDebugSources</code>:</p>
  
  <blockquote>
    <p>Could not create service of type TaskHistoryRepository using TaskExecutionServices.createTaskHistoryRepository().
    java.io.FileNotFoundException: /var/lib/jenkins/workspace/test/.gradle/4.5/taskHistory/taskHistory.lock (Permission denied)</p>
  </blockquote>
  
  <p>What's the right way to grant Jenkins permissions to access this file and other files it needs to use?</p>