Auto-generated build folder too long on jenkins slave
So far, our solution has been a rather hacky one:
We simply mapped the long base folder to a network drive (specifically:
subst x: .x:
and then continued on from there.
Our solution was to set the workspace path manually in the Jenkinsfile, created from the sanitized form of the branch name:
if (branchName) { // if this build has the branch name set path = path.split(pathSeparator) // take the current path def currentWs = path[-1] // -1 as index denotes the first item from the end (the last one) def workspaceRoot = path[0..<-1].join(pathSeparator) // joins all path elements from 0 to (not including) the last, effectively stripping the last path part with hte crazy-long alphanumeric ID // Here is where we make branch names safe for directories by replacing all special characters except '_' with '_' // Of concern are the list of non-permitted characters for windows (/\:*?"<>|) and - for linux, but it's easier to replace all non-word characters def newWorkspace = env.BRANCH_NAME.replaceAll("\\W", '_') if (newWorkspace.length() > 61) { newWorkspace = newWorkspace.substring(0,61) // trim the overall length to 60 characters - even though git doesn't have a limit, OSes do have. } if (currentWs =~ '@') { // Add on the '@n' suffix if it was there newWorkspace = "${newWorkspace}@${currentWs.split('@')[-1]}" } path = "${workspaceRoot}${pathSeparator}${newWorkspace}"}ws(path) { // Do the build-related stuff here in the newly composed, safe and short workspace directory