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

Multibranch pipeline cannot find Jenkinsfile with Check out to a sub-directory

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • pipeline
    • None
    • Jenkins ver. 2.19.2
      Pipeline 2.4
      Pipeline: Multibranch 2.9
      Ubuntu 16 LTS

      Problem Description

      Without Additional Behaviors > Check out to a sub-directory, Jenkins can find my Jenkinsfile.

      If I add Additional Behaviors > Check out to a sub-directory, Jenkins clones in the specified directory, but it still looks for Jenkinsfile at the top of the workspace.


      That's all for the bug report. I add the following for the sake of users who are experiencing the particular way that this problem manifests, and are searching for an explanation.

      Symptom

      When at first you do not use Additional Behaviors > Check out to a sub-directory a Jenkinsfile will be placed at the top of the workspace, and everything will work as expected.

      Then if you change your mind and start using Additional Behaviors > Check out to a sub-directory, Jenkins will forever use your old Jenkinsfile that remains at the top of the workspace--Jenkins will not see any updates to the Jenkinsfile that now appears in the sub-directory.

      Workaround

      First, do not use Additional Behaviors > Check out to a sub-directory in the Multibranch Pipeline Configuration.

      In Jenkinsfile, check out the main repository in the subdirectory using dir():

      dir('subDir') {
          checkout scm
      }

      See my StackOverflow answer for a discussion of checking out additional repositories.

          [JENKINS-40267] Multibranch pipeline cannot find Jenkinsfile with Check out to a sub-directory

          jglick this doesn't make sense to me at all!!! The loading of the Jenkinsfile happens before the checkout on the node...

          Stephen Connolly added a comment - jglick this doesn't make sense to me at all!!! The loading of the Jenkinsfile happens before the checkout on the node...

          Jesse Glick added a comment -

          The “workaround” is the correct approach. This Git plugin extension is only useful for freestyle projects.

          The loading of the Jenkinsfile happens before the checkout on the node

          Right—he is talking about loading of Jenkinsfile from the master …@script directory.

          Jesse Glick added a comment - The “workaround” is the correct approach. This Git plugin extension is only useful for freestyle projects. The loading of the Jenkinsfile happens before the checkout on the node Right—he is talking about loading of Jenkinsfile from the master …@script directory.

          John McGehee added a comment -

          I agree that the workaround is the correct approach.

          I would suggest that you disable Additional Behaviors > Check out to a sub-directory option so that nobody can get into that strange situation that I got myself into.  However I do not care to press the issue.

          John McGehee added a comment - I agree that the workaround is the correct approach. I would suggest that you disable  Additional Behaviors > Check out to a sub-directory  option so that nobody can get into that strange situation that I got myself into.  However I do not care to press the issue.

          Jesse Glick added a comment -

          Would be an RFE for git-plugin to conditionally display this option only if the AncestorInPath is an AbstractProject.

          Jesse Glick added a comment - Would be an RFE for git-plugin to conditionally display this option only if the AncestorInPath is an AbstractProject .

          John McGehee added a comment -

          This is a git-plugin issue, not a Pipeline issue.  Created JENKINS-43052 per jglick's suggestion.

          John McGehee added a comment - This is a git-plugin issue, not a Pipeline issue.  Created  JENKINS-43052  per jglick 's suggestion.

            Unassigned Unassigned
            jmcgeheeiv John McGehee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: