0

I have a Jenkins folder that contains 4 subjobs. I want each subjob to use same custom workspace with folder name.

I found this thread discuss about Folder name as Enviroment Variable.

for each subjob, I set custom workspace to C:\CI\workspace/${JOB_NAME%/*}

I set custom workspace from configure->Advanced Project Options->Use custom workspace

but when I build subjobs, I got this error.

java.io.IOException: Failed to mkdirs: C:\CI\workspace/${JOB_NAME%/*}
    at hudson.FilePath.mkdirs(FilePath.java:1171)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1210)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:566)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:491)
    at hudson.model.Run.execute(Run.java:1737)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)
Finished: FAILURE

Please for advice, I do not know where I'm wrong.

Thanks.

okokok126
  • 1
  • 1
  • 2
  • Running jenkins on Windows your env var should be %JOB_NAME% and not ${JOB_NAME%/*}. See [here](https://stackoverflow.com/a/8607291/4175515) – Joao Vitorino Nov 08 '17 at 15:11
  • Thanks for your reply. if I set custom workspace to C:\CI\workspace\%JOB_NAME%, Jenkins will create a directory C:\CI\workspace\%JOB_NAME% – okokok126 Nov 09 '17 at 05:33

2 Answers2

0

I would suggest to move your code to c:/users/YOURUSERNMAE/.jenkins folder and provide path as below in custom work space folder path

${JENKINS_HOME}/yourFolderNameWherePOM.XMLexists

0

Please use it the correct way in groovy :

customWorkspace "C:/CI/${JOB_BASE_NAME}"

OR

customWorkspace "C:/CI/${JOB_NAME}"
Sid
  • 4,905
  • 1
  • 17
  • 17