Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Blue Ocean workspace Path Too Long

We are using Jenkins Blue Ocean to build .Net applications on Windows 2012 r2 Jenkins Slaves. We use a Jenkinsfile inside the git repos to define the build pipelines.

With a couple of the projects we get a build failure due to the workspace build path being too long for Windows to handle.
This generally happens with nuget pack and npm install commands which max out the max path.

The specified path, file name, or both are too long. 
The fully qualified file name must be less than 260 characters, 
and the directory name must be less than 248 characters.

script returned exit code 1

As we can't affect the length of the Visual Studio Solution nuget package paths how do we drop the workspace folder down to something Windows can handle?


Thanks to the suggestion by Mutsa here is what we ended up with in our Jenkinsfile:

pipeline {
agent {
    node {
        label 'win'
        customWorkspace "ws\\${JOB_NAME.replace("%2F", "_")}"
    }
}

Which can be seen in context in our .net core Wakeboard UK website repo on GitHub.

like image 418
j3r3m7 Avatar asked May 19 '17 09:05

j3r3m7


People also ask

How do I change the workspace directory in Jenkins pipeline?

So if you wish to change the Jenkins workspace, all you've do is change the path of your JENKINS_HOME. For slave nodes, specify the default workspace on the slave machine in the slave configuration under Manage Jenkins > Manage Nodes > > Configure > Remote FS root.

How do I access Jenkins blue ocean?

Accessing Blue Ocean Once a Jenkins environment has Blue Ocean installed and you log in to the Jenkins classic UI, you can access the Blue Ocean UI by selecting Open Blue Ocean on the left side of the screen. Alternatively, you can access Blue Ocean directly by appending /blue to the end of your Jenkins server's URL.

What is the blue ocean in Jenkins?

What is Blue Ocean? Blue Ocean rethinks the user experience of Jenkins. Designed from the ground up for Jenkins Pipeline, Blue Ocean reduces clutter and increases clarity for all users.


1 Answers

For declarative pipeline use customworksace option to override the default path within your node, docker or dockerfile section. See example.

agent {
node {
    customWorkspace '/some/other/path'
}

It can be a relative path in respect to the workspace root or an absolute path.

like image 156
Mutsa Magonde Avatar answered Sep 22 '22 10:09

Mutsa Magonde