title: can not create file via Groovy code(or java code) in jenkinsfile of a pipeline job on Jenkins
body: <pre><code>pipeline {
      agent any
  
      stages {
          stage('Build') {
              steps {
                  echo 'Building..'
                  echo "whoami".execute().text
                  script {
                      File f = new File('/home/jenkins/test2.txt');
                      f.createNewFile();
                  }
              }
          }
          stage('Test') {
              steps {
                  echo 'Testing..'
              }
          }
          stage('Deploy') {
              steps {
                  echo 'Deploying....'
              }
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <blockquote>
    <p>Jenkins console log: (got exception: Started by user Edgar Yu Running
    in Durability level: MAX_SURVIVABILITY [Pipeline] node Running on
    Jenkins in /var/jenkins_home/workspace/test2 [Pipeline] { [Pipeline]
    stage [Pipeline] { (Build) [Pipeline] echo Building.. [Pipeline] echo
    jenkins</p>
    
    <p>[Pipeline] script [Pipeline] { [Pipeline] } [Pipeline] // script
    [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Test)
    Stage 'Test' skipped due to earlier failure(s) [Pipeline] } [Pipeline]
    // stage [Pipeline] stage [Pipeline] { (Deploy) Stage 'Deploy' skipped
    due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline]
    } [Pipeline] // node [Pipeline] End of Pipeline
    <strong>java.io.IOException: Permission denied</strong>    at java.io.UnixFileSystem.createFileExclusively(Native Method)  at
    java.io.File.createNewFile(File.java:1012)</p>
  </blockquote>