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

          John McGehee created issue -
          John McGehee made changes -
          Description Original: 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 does clone 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.

          If you first 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 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. Pretty darn hard to diagnose...

          New: 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 does clone 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.

          If you first 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 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. Pretty darn hard to diagnose...

          John McGehee made changes -
          Description Original: 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 does clone 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.

          If you first 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 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. Pretty darn hard to diagnose...

          New: h2. 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 does clone in the specified directory, but it still looks for {{Jenkinsfile}} at the top of the workspace.

          Originally I was thinking that the {{Jenkinsfile}} reader should track _Additional Behaviors > Check out to a sub-directory_, but after gaining some experience with

          ----

          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.

          h2. Symptom
          If you first 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 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. Pretty darn hard to diagnose...

          h2. Workaround
          First, do not use _Additional Behaviors > Check out to a sub-directory_ in the Multibranch Pipeline Configuration.

          Then, in {{Jenkinsfile}}, {{stash}} the repo in the workspace directory, and {{unstash}} it into a subdirectory:
          {code:java}stage("setup") {
              node("sw") {
                  deleteDir()
                  checkout scm
                  stash name: "repo"
              }
          }

          stage("test") {
              node("sw") {
                  deleteDir()
                  dir("subdir") {
                      unstash "repo"
                   }
                  // Test stuff
              }
          }{code}
          John McGehee made changes -
          Description Original: h2. 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 does clone in the specified directory, but it still looks for {{Jenkinsfile}} at the top of the workspace.

          Originally I was thinking that the {{Jenkinsfile}} reader should track _Additional Behaviors > Check out to a sub-directory_, but after gaining some experience with

          ----

          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.

          h2. Symptom
          If you first 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 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. Pretty darn hard to diagnose...

          h2. Workaround
          First, do not use _Additional Behaviors > Check out to a sub-directory_ in the Multibranch Pipeline Configuration.

          Then, in {{Jenkinsfile}}, {{stash}} the repo in the workspace directory, and {{unstash}} it into a subdirectory:
          {code:java}stage("setup") {
              node("sw") {
                  deleteDir()
                  checkout scm
                  stash name: "repo"
              }
          }

          stage("test") {
              node("sw") {
                  deleteDir()
                  dir("subdir") {
                      unstash "repo"
                   }
                  // Test stuff
              }
          }{code}
          New: h2. 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.

          h2. 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 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.

          h2. Workaround
          First, do not use _Additional Behaviors > Check out to a sub-directory_ in the Multibranch Pipeline Configuration.

          Then, in {{Jenkinsfile}}, {{stash}} the repo in the workspace directory, and {{unstash}} it into a subdirectory:
          {code:java}stage("setup") {
              node("sw") {
                  deleteDir()
                  checkout scm
                  stash name: "repo"
              }
          }

          stage("test") {
              node("sw") {
                  deleteDir()
                  dir("subdir") {
                      unstash "repo"
                   }
                  // Test stuff
              }
          }{code}
          John McGehee made changes -
          Description Original: h2. 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.

          h2. 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 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.

          h2. Workaround
          First, do not use _Additional Behaviors > Check out to a sub-directory_ in the Multibranch Pipeline Configuration.

          Then, in {{Jenkinsfile}}, {{stash}} the repo in the workspace directory, and {{unstash}} it into a subdirectory:
          {code:java}stage("setup") {
              node("sw") {
                  deleteDir()
                  checkout scm
                  stash name: "repo"
              }
          }

          stage("test") {
              node("sw") {
                  deleteDir()
                  dir("subdir") {
                      unstash "repo"
                   }
                  // Test stuff
              }
          }{code}
          New: h2. 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.

          h2. 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 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.

          h2. Workaround
          First, do not use _Additional Behaviors > Check out to a sub-directory_ in the Multibranch Pipeline Configuration.

          In {{Jenkinsfile}}, {{stash}} the repo in the workspace directory, and {{unstash}} it into a subdirectory:
          {code:java}stage("setup") {
              node("sw") {
                  deleteDir()
                  checkout scm
                  stash name: "repo"
              }
          }

          stage("test") {
              node("sw") {
                  deleteDir()
                  dir("subdir") {
                      unstash "repo"
                   }
                  // Test stuff
              }
          }{code}
          John McGehee made changes -
          Description Original: h2. 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.

          h2. 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 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.

          h2. Workaround
          First, do not use _Additional Behaviors > Check out to a sub-directory_ in the Multibranch Pipeline Configuration.

          In {{Jenkinsfile}}, {{stash}} the repo in the workspace directory, and {{unstash}} it into a subdirectory:
          {code:java}stage("setup") {
              node("sw") {
                  deleteDir()
                  checkout scm
                  stash name: "repo"
              }
          }

          stage("test") {
              node("sw") {
                  deleteDir()
                  dir("subdir") {
                      unstash "repo"
                   }
                  // Test stuff
              }
          }{code}
          New: h2. 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.

          h2. 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 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.

          h2. 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():
          {code:java}dir('subDir') {
              checkout scm
          }{code}

          See my StackOverflow answer for a [discussion of checking out additional repositories|http://stackoverflow.com/a/40392423/2850565].
          Jesse Glick made changes -
          Resolution New: Won't Fix [ 2 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          John McGehee made changes -
          Description Original: h2. 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.

          h2. 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 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.

          h2. 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():
          {code:java}dir('subDir') {
              checkout scm
          }{code}

          See my StackOverflow answer for a [discussion of checking out additional repositories|http://stackoverflow.com/a/40392423/2850565].
          New: h2. 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.
          h2. 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.
          h2. 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():
          {code:java}
          dir('subDir') {
              checkout scm
          }{code}
          See my StackOverflow answer for a [discussion of checking out additional repositories|http://stackoverflow.com/a/40392423/2850565].
          John McGehee made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

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

              Created:
              Updated:
              Resolved: