10

By default, jobs on a Jenkins node will be stored in [Remote FS root]\workspace\.

Currently, [Remote FS root] is set to D:\, so my jobs are in D:\workspace\. Due to the 255-characters limit on Windows, I need my job directories to be directly at the root of the drive.

How to set the workspace root directory to D:\?

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130

2 Answers2

7

We have to specify the following argument on startup of the Jenkins master node:

-Dhudson.model.Slave.workspaceRoot=D:/

To do so, find the jenkins.xml configuration file in $JENKINS_HOME and complete the <arguments></arguments> section.

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
  • 2
    It's worth noting that the [documentation for Jenkins properties](https://wiki.jenkins.io/display/JENKINS/Features+controlled+by+system+properties) states that this property specifies the "name of the folder within the slave root directory to contain workspaces". So, if we wanted to use `D:\jobs` instead of `D:\workspace` on slaves, this property just needs to be set to `jobs`. It seems that specifying an absolute path overrides the use of the slave root directory as well. – darrenp Jan 16 '18 at 20:49
3

By default, jobs on a Jenkins slave will be stored in [Remote FS root]\workspace\

It seems that, at least on Windows, this is not actually true.

I'm running Jenkins 1.480.3, and my slaves are run via jenkins-slave.exeand jenkins-slave.xml on Windows nodes.

Neither the XML file nor the service parameters store any path information, and *the workspace directory is created at the location of the jenkins-slave.exe, which is the same as the setting under http://server/jenkins/computer/node_name/configure -> Remote FS root the help for which reads:

A slave needs to have a directory dedicated to Jenkins. Specify the absolute path of this work directory on the slave, such as '/var/jenkins' or 'c:\jenkins'. This should be a path local to the slave machine. (...)

Slaves do not maintain important data (other than active workspaces of projects last built on it), so you can possibly set the slave workspace to a temporary directory. The only downside of doing this is that you may lose the up-to-date workspace if the slave is turned off.

So it seems it is actually possible to set the workspaceon the slave via the Jenkins FS root for the slaves.

Also related: https://issues.jenkins-ci.org/browse/JENKINS-12667

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
  • 1
    Yes, it's possible with the Jenkins FS root and that's why it's made for. However, jobs are put into `[Remote FS root]\workspace` whereas I need them to be in `[Remote FS root]`, which means my job1 will be in `D:\job1` instead of `D:\workspace\job1`. – Stéphane Bruckert Nov 07 '14 at 15:36
  • @StéphaneBruckert - the linked Jenkins issues says the same. Guess itÄs a valid case to not want it under the FS root/workspace. – Martin Ba Nov 07 '14 at 15:43
  • Indeed. The workaround I suggest is good for now even if I am still hoping that this feature will be added one day. – Stéphane Bruckert Nov 07 '14 at 15:45