1

I have a Jenkins multi-configuration project that I want to build on two slaves (Slave-1 and Slave-2) which are located on two different VM's. I am having a problem with how Jenkins attempts to create different workspaces for each slave. I want to use the same workspace path on each VM.

I am getting my project files from Perforce and want to put them in the directory c:\workspace on both VM's. However when I run a build, I look on the VM that has Slave-1 and it stores the project files under:

c:\workspace\label\Slave-1

On the other VM the project files is under:

c:\workspace\label\Slave-2

The folder 'label' under c:\workspace was the slave name I input for the configuration matrix.

How do I override Jenkins to put my project files under c:\workspace on each VM (without the \label\Slave_name folders)? I understand Jenkins does this to avoid confusion but my workspaces are on completely different VM's that won't interact with each other in any way. I have to use the c:\workspace directory in order to build properly.

Stew C
  • 553
  • 1
  • 8
  • 22
  • Possible duplicate of [How to set the workspace root directory on Jenkins slaves?](https://stackoverflow.com/questions/23780554/how-to-set-the-workspace-root-directory-on-jenkins-slaves) – Stéphane Bruckert May 22 '17 at 20:14

2 Answers2

1

You can start Jenkins with extra params:

-Dhudson.model.Slave.workspaceRoot=c:\workspace

Taken from here: https://issues.jenkins-ci.org/browse/JENKINS-12667

Slav
  • 25,168
  • 9
  • 69
  • 95
  • I added the parameter to my .xml file's argument but looking at the logs, it shows Jenkins is switching my root directory mid-build. – Stew C May 13 '15 at 22:18
  • @Stew C mid-build? During a build step, Jenkins passes control to whatever step is executing. So, if it's really mid-build, then you should review your build scripts – Slav May 14 '15 at 12:48
0

Terms:

UnifiedDir: the target dir that you want to use that is the same on both VMs Workspace: the dir that Jenkins creates that is unique to each VM

To get around the workspace isolation and unique naming, your build script should copy the entire workspace (or what you need from it) into the target unified directory. Then a Second call in your "Workspace\Build SCript" should call the "UnifiedDir\Build Script"

Now you have a unified workspace between build nodes. Just make sure you nuke the contents of this UnifiedDir BEFORE you copy the WORKSPACE contents over.