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.
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.