Multibranch Pipeline Workspace starts with a '-'

Article ID:360034932431
1 minute readKnowledge base


Sometimes the workspace generated by a Multibranch Pipeline job starts with a '-' which causes issues with scripts.


This issue comes from the way the Branch API Plugin was generating workspace directory names. It was taking the git branch name and cutting it. In case the git branch contained '-' and the cut happened at the wrong place, it did not make sure the generated name did not start with a '-'. A fix has been provided for this in version 2.5.3 of the Branch API Plugin.


In case updating to version 2.5.3 of the Branch API Plugin is not an option, you can add -Djenkins.branch.WorkspaceLocatorImpl.PATH_MAX=<desired_workspace_length> to make sure the cut is done elsewhere (see How to add Java arguments to Jenkins? for details on adding this argument).

Important note: setting the value to 0 means unlimited length. You might want to be careful with this setting as some environments don’t handle long paths well. Refer to the documentation of your file system to know its specific limitations.