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

Leading - in workspace directory names mangled in multibranch pipeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • branch-api-plugin
    • None
    • jenkins-war:2.176.1
      branch-api-plugin: 2.5.2
    •  branch-api-2.5.3

      Apparently, some of our workspaces for specific branch names are mangled in a way that the directories start with a "-" (or multiple!). This would require some special handling in scripts and we would like to avoid that.

       

      There also have been some discussions about this special case in the now obsolete implementation in JENKINS-38706:

      https://issues.jenkins-ci.org/browse/JENKINS-38706?focusedCommentId=272733&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-272733

      https://issues.jenkins-ci.org/browse/JENKINS-38706?focusedCommentId=324422&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-324422

      https://issues.jenkins-ci.org/browse/JENKINS-38706?focusedCommentId=345815&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-345815

      https://issues.jenkins-ci.org/browse/JENKINS-38706?focusedCommentId=348257&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-348257

      I had a look and it seems to happen here:

      https://github.com/jenkinsci/branch-api-plugin/blob/master/src/main/java/jenkins/branch/WorkspaceLocatorImpl.java#L193

       

      It can be tested with this small java program:

       

      import org.apache.commons.lang3.StringUtils;
      public class Test {
          public static void main(String args[]) {
              int MAX_LENGTH=32;
              String fullName= "JIRA-1054_rename_1234_to_abcdef_try2";
              String mnemonic = mnemonicOf(fullName);
              String path = StringUtils.right(mnemonic, MAX_LENGTH);
              System.out.println(path);
          }
          private static String mnemonicOf(String name) {
              // Do not need the complexity of NameMangler here, since we uniquify as needed.
              return name.replaceAll("(%[0-9A-F]{2}|[^a-zA-Z0-9-_.])+", "_");
          }
      }
      

      For the moment i have increased MAX_LENGTH on our jenkins, but I would really love to see this fixed in Jenkins.

            rompic Roman Pickl
            rompic Roman Pickl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: