title: why is mkdir trying (and rightfully failing) to create the existing root directories?
body: <p>I have a step in my jenkins-pipeline script that is supposed to create a directory. The relevant portion looks like this:</p>
  
  <pre><code>steps.println 'target file path: ' + folder.toString()
      steps.println 'who am i?: ' + "whoami".execute().text
  
      def sout = new StringBuilder()
      def serr = new StringBuilder()
      def cmd = ('mkdir -v -p ' + folder.toString())
      steps.println 'cmd = ' + cmd
      def proc = cmd.execute()
      proc.consumeProcessOutput(sout, serr)
      proc.waitForOrKill(1000)
  
      if (proc.exitValue() == 0){
          steps.println 'Success: ' + sout
      }
      else {
          steps.println 'ERROR: ' + serr
          throw new Exception('Could not create directory "' + folder.toString() +'"')
      }
  </code></pre>
  
  <p>However, when the code executes, I get the following output:</p>
  
  <pre><code>Destination Path = 
  /home/jenkins/jenkins_slave/workspace/atlassianPublishTest_master-6R2ESEJZC6HJUUVOOHAQIN7KEMQAPLOBYDS3KQUR5VE6R5RBIUXA/files/docs/Storfirst Release Notes.pdf
  [Pipeline] echo
  target file name: Storfirst Release Notes.pdf
  [Pipeline] echo
  target file path: 
  /home/jenkins/jenkins_slave/workspace/atlassianPublishTest_master-6R2ESEJZC6HJUUVOOHAQIN7KEMQAPLOBYDS3KQUR5VE6R5RBIUXA/files/docs
  [Pipeline] echo
  who am i?: jenkins
  
  [Pipeline] echo
  cmd = mkdir -v -p 
  /home/jenkins/jenkins_slave/workspace/atlassianPublishTest_master-6R2ESEJZC6HJUUVOOHAQIN7KEMQAPLOBYDS3KQUR5VE6R5RBIUXA/files/docs
  [Pipeline] echo
  ERROR: mkdir: cannot create directory ‘/home/jenkins’: Permission denied
  </code></pre>
  
  <p>I've verified that the permissions are correct for all the folders (home is owned by root, the rest are owned by jenkins and have permissions for everything except global write). Only the bottom two folders do not exist, the rest exist and are properly permissioned.</p>
  
  <p>When I execute the command on the jenkins node by hand, it works as expected, but as you can see, even though this is running as the owner of the folder, it looks like it is trying to create the root folder (/home/jenkins) which it obviously doesn't have permission to create.</p>
  
  <p>Its worth noting the reason I am using the mkdir command instead of groovy's File.mkdirs() is because that silently failed to create the directories also.</p>
  
  <p>Can someone please give me an idea as to what I'm doing wrong here?
  Thank you</p>