Answers: <p>Issue got resolved with the use of <a href="https://www.jenkins.io/doc/pipeline/steps/file-operations/" rel="nofollow noreferrer">File Operations Plugin</a> methods like <code>folderCreateOperation</code> &amp; <code>fileCreateOperation</code>. Example code snippet below:</p>
  <pre><code>def path = &quot;${workspace}\submodule\newFolder&quot;
  fileOperations([folderCreateOperation(folderPath: path)])
  dir(path) {
      fileOperations([fileCreateOperation(fileName: 'newFile.properties', fileContent: 'Git_Tag=${env.Git_Tag}')])
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2022-04-29T18:08:59.970Z
Answers: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answers: Community
Answers: CC BY-SA 4.0
Answers: 2022-04-29T09:59:09.790Z
Answers: 2022-04-29T18:54:32.357Z
Answers: 2022-04-29T18:54:32.357Z
Answers: Sreehari
Body: <p>I have a Jenkins job which runs on a slave node on another machine, both master and slave run on windows. The slave node is being run as a windows service. The main repository has git submodule included. After checking-out the code for both the main and sub module repositories, I need to create a folder inside of the submodule folder and write a file into it with some basic deployment details like tag, version, etc. Structure is something like this:</p>
  <p><em><strong><code>main -&gt; submodule -&gt; {newfolder} -&gt; {newfile}</code></strong></em></p>
  <p>I am using the mkdir() to create the folder, but it is not being created. I have also tried the dir() method. But nothing seems to be working. Can anyone help on this:</p>
  <ol>
  <li>Do I need to provide elevated permissions set for the windows service used to trigger the slave node?</li>
  <li>Do I need to provide permissions at folder level?</li>
  </ol>
  <p>Any other check that I am missing, please help.</p>
  
Tags: <jenkins-pipeline><git><permissions>
Title: Create a folder in slave node using Jenkins pipeline groovy script
UserDisplayName: Sreehari
ThreadText: # Create a folder in slave node using Jenkins pipeline groovy script
  
  (Asked by: username_0 on 2022-04-26)
  
  I have a Jenkins job which runs on a slave node on another machine, both master and slave run on windows. The slave node is being run as a windows service. The main repository has git submodule included. After checking-out the code for both the main and sub module repositories, I need to create a folder inside of the submodule folder and write a file into it with some basic deployment details like tag, version, etc. Structure is something like this:
  
  ***`main -> submodule -> {newfolder} -> {newfile}`***
  
  I am using the mkdir() to create the folder, but it is not being created. I have also tried the dir() method. But nothing seems to be working. Can anyone help on this:
  
  1. Do I need to provide elevated permissions set for the windows service used to trigger the slave node?
  2. Do I need to provide permissions at folder level?
  
  Any other check that I am missing, please help.
  
  **Tags:** jenkins-pipeline, git, permissions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-04-29. Score: 0 | Accepted answer
  
  Issue got resolved with the use of [File Operations Plugin](https://www.jenkins.io/doc/pipeline/steps/file-operations/) methods like `folderCreateOperation` & `fileCreateOperation`. Example code snippet below:
  
  ```
  def path = "${workspace}\submodule\newFolder"
  fileOperations([folderCreateOperation(folderPath: path)])
  dir(path) {
      fileOperations([fileCreateOperation(fileName: 'newFile.properties', fileContent: 'Git_Tag=${env.Git_Tag}')])
  }
  
  ```
  
  > **Comments:**
  > **username_1**: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).  
  
  ---
  
  