Multibranch Pipeline Workspace starts with a '-'

Issue

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

Environment

Resolution

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.

Workaround

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.

References

Have more questions?

0 Comments

Please sign in to leave a comment.