Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54968

“path sanitization ineffective when using legacy Workspace Root Directory” ending in slash (was: Branch API 2.1.1 Path Length)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: In Review (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: branch-api-plugin
    • Labels:
      None
    • Environment:
      Windows 10
      Jenkins 2.138.3
      Branch API 2.1.1
    • Similar Issues:

      Description

      I have a multibranch project that recently started spitting out weird errors, due to path length being too long. This issue was traced down to recent the changes in this plugin. I look briefly around in your code for a way around this. My project depends on the PATH_MAX variable. When I switched to the new MAX_LENGTH variable, it gave the full name not a shorten version. Can please implement a way to shorten the path?

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Update to 2.1.2. Otherwise, I cannot help without complete steps to reproduce the problem from scratch.

            Show
            jglick Jesse Glick added a comment - Update to 2.1.2. Otherwise, I cannot help without complete steps to reproduce the problem from scratch.
            Hide
            nsikkema Nick Sikkema added a comment -

            Jesse Glick
            This problem occurs due to older version Visual Studio using the old Windows API for filesystem. The max path length with this API is 260 characters. The combination of the Multibranch projects and the changes done in Branch API 2.1.0, cause path name to go over this limit. Before I was able to reduce the number of characters with the PATH_MAX variable.

            With this information, I cannot update to 2.1.2 due to this being a production environment. Additionally, I have not seen any changes in the Github that would cause me to think that this issue has been resolved. 

            Show
            nsikkema Nick Sikkema added a comment - Jesse Glick This problem occurs due to older version Visual Studio using the old Windows API for filesystem. The max path length with this API is 260 characters. The combination of the Multibranch projects and the changes done in Branch API 2.1.0, cause path name to go over this limit. Before I was able to reduce the number of characters with the PATH_MAX variable. With this information, I cannot update to 2.1.2 due to this being a production environment. Additionally, I have not seen any changes in the Github that would cause me to think that this issue has been resolved. 
            Hide
            jglick Jesse Glick added a comment - - edited

            the changes done in Branch API 2.1.0, cause path name to go over this limit

            Excepting bugs, the changes done for JENKINS-2111 should have reduced the path name length, by eliminating the need for the long random suffix, so that by default no workspace name (relative to the workspace subdirectory of the agent FS root) will exceed 32 characters.

            So again, without the ability to reproduce your problem from scratch in the most recently release version of the plugin, I cannot help. Note that extensive diagnostics are available in the jenkins.branch.WorkspaceLocatorImpl logger.

            Show
            jglick Jesse Glick added a comment - - edited the changes done in Branch API 2.1.0, cause path name to go over this limit Excepting bugs, the changes done for JENKINS-2111 should have reduced the path name length, by eliminating the need for the long random suffix, so that by default no workspace name (relative to the workspace subdirectory of the agent FS root) will exceed 32 characters. So again, without the ability to reproduce your problem from scratch in the most recently release version of the plugin, I cannot help. Note that extensive diagnostics are available in the jenkins.branch.WorkspaceLocatorImpl logger.
            Hide
            hu3bl René Hahn added a comment - - edited

            Hello guys,

            we ran into the same problem with the Branch API 2.1.2. Using 2.0.20 before (and after reverting), there are no issues with too long paths as we use PATH_MAX to shorten the path to 30 characters

            Test-wise, I created a repository called BranchAPITest on our Bitbucket Server. The only thing in the repository is a Jenkinsfile. When building this on our Jenkins, the workspace is placed at C:\ws\BranchAPITest\master for the master branch (note that our workspace-root is at C:\ws). So far, so good.

            However, when creating a new branch in this repository called really-long-branch-name-really-long-branch-name-really-long-branch-name-really-long-branc, the workspace is called C:\ws\BranchAPITest\really-long-branch-name-really-long-branch-name-really-long-branch-name-really-long-branc, which is too long, as we run into issues with some compilers due to the max path length of 260 characters on windows.

            The WorkspaceLocatorImpl logger does say the following: JENKINS-2111 path sanitization ineffective when using legacy Workspace Root Directory ‘c:\ws\${ITEM_FULL_NAME}\’; switch to ‘${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}’ as in JENKINS-8446 / JENKINS-21942

            Therefore, I guess it has something to do with our workspace root folder as we're not using the workspace folder within $JENKINS_HOME. However, on our slaves, we're also using C:\ws\ as root workspace folder by setting -Dhudson.model.Slave.workspaceRoot=C:/ws/ on the master and it is working there like a charm with the shortened paths.

            Is there a way to fix this to get is also running on the master? Or do we have to change our workspace root into the $JENKINS_HOME folder? 

             

            EDIT:

            I found a solution for this: our workspace root directory has a "\" at the end. Reviewing your code revealed that the GOOD_RAW_WORKSPACE_DIR Pattern does not include a "/" or "\" at the end. Since matches is called instead of find, the pattern does not match in our case. After removing the "\" in the config.xml, it is now working for us.

            A solution could be including the "/" and "\" as optional in the pattern to make it more robust. 

            Show
            hu3bl René Hahn added a comment - - edited Hello guys, we ran into the same problem with the Branch API 2.1.2. Using 2.0.20 before (and after reverting), there are no issues with too long paths as we use PATH_MAX to shorten the path to 30 characters Test-wise, I created a repository called BranchAPITest on our Bitbucket Server. The only thing in the repository is a Jenkinsfile. When building this on our Jenkins, the workspace is placed at C:\ws\BranchAPITest\master for the master branch (note that our workspace-root is at C:\ws). So far, so good. However, when creating a new branch in this repository called  really-long-branch-name-really-long-branch-name-really-long-branch-name-really-long-branc , the workspace is called C:\ws\BranchAPITest\really-long-branch-name-really-long-branch-name-really-long-branch-name-really-long-branc, which is too long, as we run into issues with some compilers due to the max path length of 260 characters on windows. The WorkspaceLocatorImpl logger does say the following:  JENKINS-2111 path sanitization ineffective when using legacy Workspace Root Directory ‘c:\ws\${ITEM_FULL_NAME}\’; switch to ‘${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}’ as in JENKINS-8446 / JENKINS-21942 Therefore, I guess it has something to do with our workspace root folder as we're not using the workspace folder within $JENKINS_HOME. However, on our slaves, we're also using C:\ws\ as root workspace folder by setting -Dhudson.model.Slave.workspaceRoot=C:/ws/  on the master and it is working there like a charm with the shortened paths. Is there a way to fix this to get is also running on the master? Or do we have to change our workspace root into the $JENKINS_HOME folder?    EDIT: I found a solution for this: our workspace root directory has a "\" at the end. Reviewing your code revealed that the  GOOD_RAW_WORKSPACE_DIR  Pattern does not include a "/" or "\" at the end. Since matches is called instead of find , the pattern does not match in our case. After removing the "\" in the config.xml, it is now working for us. A solution could be including the "/" and "\" as optional in the pattern to make it more robust. 
            Hide
            jglick Jesse Glick added a comment -

            Thanks René Hahn for tracking that down. Easily fixed once diagnosed. Possibly the original reporter’s issue was the same, possibly something else, but anyway yours is the only thing I have to go on here so I will optimistically treat it as your issue.

            Show
            jglick Jesse Glick added a comment - Thanks René Hahn for tracking that down. Easily fixed once diagnosed. Possibly the original reporter’s issue was the same, possibly something else, but anyway yours is the only thing I have to go on here so I will optimistically treat it as your issue.

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                nsikkema Nick Sikkema
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: