[JIRA] (JENKINS-47978) Lightweight checkout not working for branches that contain forward slash '/'

2 views
Skip to first unread message

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 1:53:02 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen commented on Bug JENKINS-47978
 
Re: Lightweight checkout not working for branches that contain forward slash '/'

This fix seriously broke something. We've been at it for weeks – it still will not find Jenkinsfile in subdirectories. 

Started by user P*** S**** (p*.**)
[Thu Jan 25 10:00:01 CET 2018] Starting branch indexing...
Connecting to http://***.***.**.se using allowed.user/******Repository type: Git
Looking up asd/asd_stuff for branches
Checking branch feature/asd-things from asd/asd_stuff
‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
Skipped
Checking branch feature/ASD-123-test-doit from asd/asd_stuff
‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
Skipped
...

... although the file is clearly present and worked before this patch.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 1:53:03 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen edited a comment on Bug JENKINS-47978
This fix seriously broke something. We've been at it for weeks a week – it still will not find Jenkinsfile in subdirectories. 


Started by user P*** S**** (p**.***)

[Thu Jan 25 10:00:01 CET 2018] Starting branch indexing...
Connecting to [ http://***.***.**.se |http://%2A%2A%2A.%2A%2A%2A.%2A%2A.se/] using allowed.user/******Repository type: Git

Looking up asd/asd_stuff for branches
Checking branch feature/asd-things from asd/asd_stuff
      ‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
    Skipped
Checking branch feature/ASD-123-test-doit from asd/asd_stuff
      ‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
    Skipped
...

... although the file is clearly present and worked before this patch.

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 1:54:03 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen edited a comment on Bug JENKINS-47978
This fix seriously broke something. We've been at it for a week – it still will not find Jenkinsfile in subdirectories. 


Started by user P*** S**** (p**.***)
[Thu Jan 25 10:00:01 CET 2018] Starting branch indexing...
Connecting to [http://***.***.**.se|http://%2A%2A%2A.%2A%2A%2A.%2A%2A.se/] using allowed.user/******Repository type: Git
Looking up asd/asd_stuff for branches
Checking branch feature/asd-things from asd/asd_stuff
‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
Skipped
Checking branch feature/ASD-123-test-doit from asd/asd_stuff
‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
Skipped
...

... although the file is clearly present and worked before this patch. Jenkinsfile in root path of a repo will work just fine, in a subdirectory, not so fine. 

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 2:00:02 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen reopened an issue
 

.. broke other things containing slash '/', see comment.

Jenkins / Bug JENKINS-47978
Change By: bjorn rohlen
Resolution: Fixed
Status: Resolved Reopened

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 2:05:03 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen edited a comment on Bug JENKINS-47978
This fix seriously broke something. We've been at it for a week – it still will not find Jenkinsfile in subdirectories. 

Started by user P*** S**** (p**.***)
[Thu Jan 25 10:00:01 CET 2018] Starting branch indexing...
Connecting to [http://***.***.**.se|http://%2A%2A%2A.%2A%2A%2A.%2A%2A.se/] using allowed.user/******Repository type: Git
Looking up asd/asd_stuff for branches
Checking branch feature/asd-things from asd/asd_stuff
‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
Skipped
Checking branch feature/ASD-123-test-doit from asd/asd_stuff
‘javaproject/asd-stuff-autotest/Jenkinsfile’ not found
Skipped
...

... although the file is clearly present and worked before this patch. Jenkinsfile in root path of a repo will work just fine, in a subdirectory, not so fine. 


To clarify: If you specify Jenkinsfile in a subdirectory, that will no longer work. I've reproduced this numerous times before re-opening this issue on my own repos. 

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 2:08:02 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen edited a comment on Bug JENKINS-47978
REPOENING ISSUE

.. broke other things containing slash '/', see previous comment.

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 13, 2018, 2:08:03 PM2/13/18
to jenkinsc...@googlegroups.com
bjorn rohlen edited a comment on Bug JENKINS-47978
REPOENING REOPENING ISSUE


.. broke other things containing slash '/', see previous comment.

vivek.pandey@gmail.com (JIRA)

unread,
Feb 14, 2018, 3:41:03 PM2/14/18
to jenkinsc...@googlegroups.com

bjorn rohlen Ok, so to confirm Jenkinsfile is getting picked correctly when at its located at repository/branch root. If placed inside a subdirectory its not detected.

I checked with github branch source as well, Jenkinsfile discovery doesn't get picked from subdirectory. Looks like this is consistent compared to github branch source.

Stephen Connolly can you shade some light as whats expected behavior here? 

stephen.alan.connolly@gmail.com (JIRA)

unread,
Feb 15, 2018, 4:16:03 PM2/15/18
to jenkinsc...@googlegroups.com

If the SCMSourceCriteria is looking for a file at a non-root path, that is supposed to work. If it is not working for GitHub then that is a bug in GitHub, as is not working for Bitbucket here.

https://github.com/jenkinsci/workflow-multibranch-plugin/pull/59 was the PR that enabled the use case in multibranch pipelines and is aligned with the architectural designs of SCM API.

stephen.alan.connolly@gmail.com (JIRA)

unread,
Feb 15, 2018, 4:21:02 PM2/15/18
to jenkinsc...@googlegroups.com

it is possible that GitHub Branch Source has a regression, but https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java#L193 is passing (yes based on an evil replayed capture of real github), so unless https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMProbe.java#L135-L151 has a bug, we should be detecting the Jenkinsfile at the path and creating the branch, and then loading the file from the lightweight checkout (which the test "claims" is working)

 

So it looks like GitHub is working with child paths... of course I don't trust the wiremock tests and would love to rip them out... but GitHub has that rate limit that makes testing live a nightmare!

bjorn.rohlen@gmail.com (JIRA)

unread,
Feb 28, 2018, 7:48:04 AM2/28/18
to jenkinsc...@googlegroups.com

Well, unfortunately it does not, as confirmed by Vivek and myself.

This is still an issue and breaking projects. 

atikhonova@parallels.com (JIRA)

unread,
Apr 9, 2018, 11:47:02 AM4/9/18
to jenkinsc...@googlegroups.com

I can confirm that the issue is not in Bitbucket branch source plugin. I have tested 2.2.10 (which is the latest at the time of writing) with Bitbucket Server and Jenkinsfile placed in build/test.jenkinsfile in my repository. Flawless.

atikhonova@parallels.com (JIRA)

unread,
Apr 9, 2018, 11:52:02 AM4/9/18
to jenkinsc...@googlegroups.com
Anna Tikhonova edited a comment on Bug JENKINS-47978
I can confirm that the issue there is not an issue in Bitbucket branch source plugin. I have tested 2.2.10 (which is the latest at the time of writing) with Bitbucket Server and Jenkinsfile placed in build/test.jenkinsfile in my repository. Flawless With 'master' branch it is flawless . However, when I put it to branch 'feature/test', in the console output I have:
{code:java}
Lightweight checkout support not available, falling back to full checkout.
Checking out git ssh://localhost:7999/bitbucket/~atikhonova/test.git into /var/lib/jenkins/workspace/test@script to read build/test.jenkinsfile
{code}

atikhonova@parallels.com (JIRA)

unread,
Apr 9, 2018, 12:01:03 PM4/9/18
to jenkinsc...@googlegroups.com
Anna Tikhonova edited a comment on Bug JENKINS-47978
I can confirm that the original issue is still there . I don't know if it is an issue in Bitbucket branch source plugin or elsewhere . I have tested 2.2.10 (which is the latest at the time of writing) with Bitbucket Server and Jenkinsfile placed in build/test.jenkinsfile in my repository. With 'master' branch it is flawless. However, when I put it to branch 'feature/test', in the console output I have:

{code:java}
Lightweight checkout support not available, falling back to full checkout.
Checking out git ssh://localhost:7999/bitbucket/~atikhonova/test.git into /var/lib/jenkins/workspace/test@script to read build/test.jenkinsfile
{code}

atikhonova@parallels.com (JIRA)

unread,
Apr 16, 2018, 12:43:02 PM4/16/18
to jenkinsc...@googlegroups.com

The workaround is to put 'refs/heads/feature/test' in Branch Specifier field of Git SCM. Not 'feature/test', not '*/feature/test'. You have to specify your git ref at full as this is the only supported case. See the breaking code in git-plugin (src/main/java//jenkins/plugins/git/GitSCMFileSystem.java):

@Extension(ordinal = Short.MIN_VALUE)
public static class BuilderImpl extends SCMFileSystem.Builder {

  @Override
  public boolean supports(SCM source) {
    return source instanceof GitSCM
      && ((GitSCM) source).getUserRemoteConfigs().size() == 1
      && ((GitSCM) source).getBranches().size() == 1
      && ((GitSCM) source).getBranches().get(0).getName().matches(
      "^((\\Q" + Constants.R_HEADS + "\\E.*)|([^/]+)|(\\*/[^/*]+(/[^/*]+)*))$"        // HERE !!
    );
  // we only support where the branch spec is obvious

atikhonova@parallels.com (JIRA)

unread,
Apr 16, 2018, 1:08:05 PM4/16/18
to jenkinsc...@googlegroups.com
Anna Tikhonova edited a comment on Bug JENKINS-47978
The workaround is to put 'refs/heads/feature/test' in Branch Specifier field of Git SCM. Not 'feature/test', not '*/feature/test'. You have to specify your git ref at full as this is the only supported case. See the breaking code in git-plugin (src/main/java//jenkins/plugins/git/GitSCMFileSystem.java):
{code:java}

@Extension(ordinal = Short.MIN_VALUE)
public static class BuilderImpl extends SCMFileSystem.Builder {

  @Override
  public boolean supports(SCM source) {
    return source instanceof GitSCM
      && ((GitSCM) source).getUserRemoteConfigs().size() == 1
      && ((GitSCM) source).getBranches().size() == 1
      && ((GitSCM) source).getBranches().get(0).getName().matches(
      "^((\\Q" + Constants.R_HEADS + "\\E.*)|([^/]+)|(\\*/[^/*]+(/[^/*]+)*))$"        // HERE !!
    );
  // we only support where the branch spec is obvious{code}
I think this simple implementation is good and the only issue here is the match failing silently. Probably, this method should put a warning to the Console why lightweight checkout failed.

atikhonova@parallels.com (JIRA)

unread,
Apr 16, 2018, 1:08:07 PM4/16/18
to jenkinsc...@googlegroups.com
Anna Tikhonova edited a comment on Bug JENKINS-47978
The workaround is to put 'refs/heads/feature/test' in Branch Specifier field of Git SCM. Not 'feature/test', not '*/feature/test'. You have to specify your git ref at full as this is the only supported case. See the breaking code in git-plugin (src/main/java//jenkins/plugins/git/GitSCMFileSystem.java):
{code:java}
@Extension(ordinal = Short.MIN_VALUE)
public static class BuilderImpl extends SCMFileSystem.Builder {

  @Override
  public boolean supports(SCM source) {
    return source instanceof GitSCM
      && ((GitSCM) source).getUserRemoteConfigs().size() == 1
      && ((GitSCM) source).getBranches().size() == 1
      && ((GitSCM) source).getBranches().get(0).getName().matches(
      "^((\\Q" + Constants.R_HEADS + "\\E.*)|([^/]+)|(\\*/[^/*]+(/[^/*]+)*))$"        // HERE !!
    );
  // we only support where the branch spec is obvious{code}
I think this simple implementation is good and the only issue here is the match failing silently. Probably, this method should put a warning to the Console explaining why lightweight checkout failed.

josephp90@gmail.com (JIRA)

unread,
Oct 27, 2018, 4:18:03 PM10/27/18
to jenkinsc...@googlegroups.com
Joseph Petersen resolved as Fixed
 

Recently tested it with 2.2.13 at least it seems fixed.

Change By: Joseph Petersen
Status: Reopened Resolved
Assignee: Vivek Pandey Joseph Petersen
Resolution: Fixed
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

josephp90@gmail.com (JIRA)

unread,
Mar 7, 2020, 1:08:00 AM3/7/20
to jenkinsc...@googlegroups.com
Joseph Petersen assigned an issue to Joseph Petersen
Change By: Joseph Petersen
Assignee: Joseph Petersen (old)
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages