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

Workspace directory names mangled in multibranch pipeline

      Apparently after a recent update of plugins, our Multibranch Pipeline jobs started putting their workspaces in mangled locations. They used to be, for example, in D:\jenkins\cm-jenkins-09\my-pipline-job\my-branch-name and now they're like D:\jenkins\cm-jenkins-09\ine-job_my-banch-name-5P5URKHPJXWGGVIWDQOJBB3N7RJECAQJGFTDCVOPY3PABO7LNTIQ

      There are several problems with this:

      1. They're difficult to read with all that garbage at the end, and the beginning of the name sometimes cut off
      2. They're not organized within the parent job like they used to be
      3. This is causing files within them to have extremely long paths such that Windows won't actually let us delete them (Jenkins, CMD, and Windows Explorer all fail to delete them)

      Let me know if I can provide any other information to help solve this. This is a private Jenkins install so I can't point you to it.

          [JENKINS-38706] Workspace directory names mangled in multibranch pipeline

          Josh Trow added a comment -

          I did read what you wrote, hence my question - nothing in this:

          Each node (master, agent) should just pay attention to when a workspace is used. (If in core, via WorkspaceList; otherwise, perhaps via WorkspaceListener.) Then record a workspaces.xml, a sibling of workspace/, with a list of records: relative workspace path, Item.fullName, timestamp.

          seems to say that you are intending to 'clean' or 'modify' or 'change' the paths from what they are today to anything nicer - just that you want to maintain a map of job to workspace for cleanup purposes down the road.

          Josh Trow added a comment - I did read what you wrote, hence my question - nothing in this: Each node (master, agent) should just pay attention to when a workspace is used. (If in core, via  WorkspaceList ; otherwise, perhaps via  WorkspaceListener .) Then record a  workspaces.xml , a sibling of  workspace/ , with a list of records: relative workspace path,  Item.fullName , timestamp. seems to say that you are intending to 'clean' or 'modify' or 'change' the paths from what they are today to anything nicer - just that you want to maintain a map of job to workspace for cleanup purposes down the road.

          Jesse Glick added a comment -

          Sorry, that was a corollary that should have been made explicit: if you are maintaining a persistent mapping of this kind, then the need to include some manner of hash in the workspace path disappears. (You would still need to translate dangerous characters to something more neutral like _.)

          Jesse Glick added a comment - Sorry, that was a corollary that should have been made explicit: if you are maintaining a persistent mapping of this kind, then the need to include some manner of hash in the workspace path disappears. (You would still need to translate dangerous characters to something more neutral like _ .)

          Tommy McNeely added a comment -

          WORKAROUND

          • For users using python virtualenv, try using 
            virtualenv --relocatable venv

             

          ... BEFORE calling "pip"

           

          That changes the shebang line to:

          #!/usr/bin/env python27

           

          ... or whatever version of python you are using, but significantly shorter.

          Tommy McNeely added a comment - WORKAROUND For users using python virtualenv, try using  virtualenv --relocatable venv   ... BEFORE calling "pip"   That changes the shebang line to: #!/usr/bin/env python27   ... or whatever version of python you are using, but significantly shorter.

          kpop added a comment - - edited

          Removing the 'garbage' at the end causes name clashes (cf. JENKINS-54640). (edit: fixed issue link)

          kpop added a comment - - edited Removing the 'garbage' at the end causes name clashes (cf. JENKINS-54640 ). (edit: fixed issue link)

          Øyvind R added a comment -

          kpop, there is no way you need over 50 base-64 characters to avoid name clashes. Git manages with just 7 hex-characters for thousands of commits.

          Øyvind R added a comment - kpop , there is no way you need over 50 base-64 characters to avoid name clashes. Git manages with just 7 hex-characters for thousands of commits.

          kpop added a comment -

          godskalk, I agree: less is certainly better, but name clashes should be avoided.

          kpop added a comment - godskalk , I agree: less is certainly better, but name clashes should be avoided.

          sascha bates added a comment -

          My workaround for this was to define a jobName and then use the jobName in the workspace. The jobName var was also to account for feature branches and builds around several different microservices that might also have the same Jira id attached to them.

          Our feature branch work is all short lived and named feature/jira-12345-some-description. Our services are named my-service-name. The below lines result in a 'my-service-name-jira-12345' workspace name. 99% of the time we don't need to look at workspaces anyway, but this makes the console log readable as well as making it possible to write directory cleanup patterns based on naming.
           
           
           
          def jobName = JOB_NAME.replaceAll(/\/\w+%2F/,'-').toLowerCase()
          ansiColor( 'xterm' ) {
            timestamps {try {node() {
              ws( "workspace/${jobName}" ) {
                stage( 'Pull Github Repository' ) {
           

          sascha bates added a comment - My workaround for this was to define a jobName and then use the jobName in the workspace. The jobName var was also to account for feature branches and builds around several different microservices that might also have the same Jira id attached to them. Our feature branch work is all short lived and named feature/jira-12345-some-description. Our services are named my-service-name. The below lines result in a 'my-service-name-jira-12345' workspace name. 99% of the time we don't need to look at workspaces anyway, but this makes the console log readable as well as making it possible to write directory cleanup patterns based on naming.       def jobName = JOB_NAME.replaceAll(/\/\w+%2F/,'-').toLowerCase() ansiColor( 'xterm' ) {   timestamps { try { node() {     ws( "workspace/${jobName}" ) {       stage( 'Pull Github Repository' ) {  

          Jesse Glick added a comment -

          This issue became obsolete with the release of the fix of JENKINS-2111.

          Jesse Glick added a comment - This issue became obsolete with the release of the fix of JENKINS-2111 .

          Suemiao Rossignol added a comment - - edited

          I am using Jenkins 2.150.2 version but still  hitting this issue?

          I also install short workspace plugins without any luck.

          Is this truly fixed?

          Suemiao Rossignol added a comment - - edited I am using Jenkins 2.150.2 version but still  hitting this issue? I also install short workspace plugins without any luck. Is this truly fixed?

          Jesse Glick added a comment -

          suemiao please do not reopen. If necessary, file a separate (but linked) bug report with complete steps to reproduce from scratch as well as FINE logs from jenkins.branch.WorkspaceLocatorImpl.

          Jesse Glick added a comment - suemiao please do not reopen. If necessary, file a separate (but linked) bug report with complete steps to reproduce from scratch as well as FINE logs from jenkins.branch.WorkspaceLocatorImpl .

            Unassigned Unassigned
            tyrelh Tyrel Haveman
            Votes:
            76 Vote for this issue
            Watchers:
            102 Start watching this issue

              Created:
              Updated:
              Resolved: