[JIRA] (JENKINS-58177) Leading - in workspace directory names mangled in multibranch pipeline

36 views
Skip to first unread message

roman@pickl.eu (JIRA)

unread,
Jun 25, 2019, 1:55:03 AM6/25/19
to jenkinsc...@googlegroups.com
Roman Pickl created an issue
 
Jenkins / Bug JENKINS-58177
Leading - in workspace directory names mangled in multibranch pipeline
Issue Type: Bug Bug
Assignee: Unassigned
Components: branch-api-plugin
Created: 2019-06-25 05:54
Environment: jenkins-war:2.176.1
branch-api-plugin: 2.5.2
Priority: Minor Minor
Reporter: Roman Pickl

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-_.])+", "_");
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

roman@pickl.eu (JIRA)

unread,
Jun 25, 2019, 1:56:01 AM6/25/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Jun 25, 2019, 1:56:01 AM6/25/19
to jenkinsc...@googlegroups.com
Roman Pickl updated an issue
{code:java}

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-_.])+", "_");
    }
}
{code}

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

roman@pickl.eu (JIRA)

unread,
Jun 25, 2019, 1:58:02 AM6/25/19
to jenkinsc...@googlegroups.com
Roman Pickl commented on Bug JENKINS-58177
 
Re: Leading - in workspace directory names mangled in multibranch pipeline

Jesse Glick maybe you could have a look at it or share your opinion, as you have worked on JENKINS-2111.

jglick@cloudbees.com (JIRA)

unread,
Jun 25, 2019, 7:16:02 AM6/25/19
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Unassigned
 

Would accept a tested patch to ensure that leading - does not appear, perhaps replaced by _, or just stripped if that leaves a valid name.

Change By: Jesse Glick
Assignee: Jesse Glick

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 4:59:03 AM6/26/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 7:46:02 AM6/26/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 7:46:02 AM6/26/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 9:51:03 AM6/26/19
to jenkinsc...@googlegroups.com
Roman Pickl stopped work on Bug JENKINS-58177
 
Change By: Roman Pickl
Status: In Progress Open

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 9:51:04 AM6/26/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 9:51:04 AM6/26/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Jun 26, 2019, 9:51:04 AM6/26/19
to jenkinsc...@googlegroups.com
Roman Pickl started work on Bug JENKINS-58177
 
Change By: Roman Pickl
Status: Open In Progress

jglick@cloudbees.com (JIRA)

unread,
Jun 26, 2019, 9:51:06 AM6/26/19
to jenkinsc...@googlegroups.com
Jesse Glick started work on Bug JENKINS-58177
 
Change By: Jesse Glick
Status: Open In Progress

jglick@cloudbees.com (JIRA)

unread,
Jun 26, 2019, 9:51:06 AM6/26/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jun 26, 2019, 9:54:03 AM6/26/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jul 1, 2019, 10:10:03 AM7/1/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jul 1, 2019, 10:10:03 AM7/1/19
to jenkinsc...@googlegroups.com
Jesse Glick stopped work on Bug JENKINS-58177
 
Change By: Jesse Glick
Status: In Progress Open

jglick@cloudbees.com (JIRA)

unread,
Jul 1, 2019, 10:10:03 AM7/1/19
to jenkinsc...@googlegroups.com

pibeitz@gmail.com (JIRA)

unread,
Jul 10, 2019, 7:21:02 AM7/10/19
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jul 10, 2019, 8:52:05 AM7/10/19
to jenkinsc...@googlegroups.com

roman@pickl.eu (JIRA)

unread,
Apr 1, 2020, 12:18:02 PM4/1/20
to jenkinsc...@googlegroups.com
Roman Pickl closed an issue as Fixed
Change By: Roman Pickl
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages