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

Github multibranch checkout

    XMLWordPrintable

Details

    Description

      Hi,

      I use github organisation plugin to build jobs inside my github orga.

      Now I ran into following problem:
      It seems that "checkout scm" does nothing for "non-master branches":

      it does not checkout the branch, the directory is stays empty. Only for the master branch it works.

      https://gist.github.com/Flow86/6b6570bc95c24d60fb06baec09103b7d

      the part of my jenkinsfile already failing is this:

      node('master') {
          stage name:"Checkout", concurrency:1
          checkout scm
          sh """set -x
                git submodule foreach "git reset --hard || true" || true
                git reset --hard || true
                git submodule update --init || true
             """
      
          stash includes: '**, .git/', excludes: 'ws/**', name: 'source', useDefaultExcludes: false
      
          sh "env"
      
          wspwd = pwd()
      }
      

      Attachments

        Activity

          jglick Jesse Glick added a comment -

          Reopen if you can describe how to reproduce from scratch. Best to debug at the code level.

          jglick Jesse Glick added a comment - Reopen if you can describe how to reproduce from scratch. Best to debug at the code level.

          okay,

          1. Create organization at github
          2. create repo inside this organization
          3. add Jenkinsfile with content from https://gist.github.com/Flow86/f9913c2006a2ff43577569355bec82c4
          4. create github organziation in jenkins, set every field

          now:
          5. let it build "master" -> this should be OK

          but:
          6. create additional branch in repo
          7. branch will be added to jenkins, but would silently fail checkout (workspace does not contain source code then)

          flow86 Florian Doersch added a comment - okay, 1. Create organization at github 2. create repo inside this organization 3. add Jenkinsfile with content from https://gist.github.com/Flow86/f9913c2006a2ff43577569355bec82c4 4. create github organziation in jenkins, set every field now: 5. let it build "master" -> this should be OK but: 6. create additional branch in repo 7. branch will be added to jenkins, but would silently fail checkout (workspace does not contain source code then)
          jglick Jesse Glick added a comment -

          Awaiting a plugin maintainer to evaluate.

          jglick Jesse Glick added a comment - Awaiting a plugin maintainer to evaluate.

          https://jenkins.one-dash.com/job/cloudbeers/job/jenkins-37028/job/feature/1/console

          Branch event
          Connecting to https://api.github.com using stephenc/****** (GitHub Personal Access Token)
          Cloning the remote Git repository
          Cloning repository https://github.com/cloudbeers/jenkins-37028.git
           > git init /var/jenkins_home/workspace/beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q@script # timeout=10
          Fetching upstream changes from https://github.com/cloudbeers/jenkins-37028.git
           > git --version # timeout=10
          using GIT_ASKPASS to set credentials GitHub Personal Access Token
           > git fetch --tags --progress https://github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/*
           > git config remote.origin.url https://github.com/cloudbeers/jenkins-37028.git # timeout=10
           > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
           > git config remote.origin.url https://github.com/cloudbeers/jenkins-37028.git # timeout=10
          Fetching upstream changes from https://github.com/cloudbeers/jenkins-37028.git
          using GIT_ASKPASS to set credentials GitHub Personal Access Token
           > git fetch --tags --progress https://github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/*
           > git config remote.origin1.url https://github.com/cloudbeers/jenkins-37028.git # timeout=10
          Fetching upstream changes from https://github.com/cloudbeers/jenkins-37028.git
          using GIT_ASKPASS to set credentials GitHub Personal Access Token
           > git fetch --tags --progress https://github.com/cloudbeers/jenkins-37028.git +refs/pull/*/head:refs/remotes/origin/pr/*
          Checking out Revision 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6 (feature)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6
          First time build. Skipping changelog.
          [Pipeline] node
          Running on agent-2 in /home/jenkins/workspace/beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q
          [Pipeline] {
          [Pipeline] stage (Checkout)
          Using the ‘stage’ step without a block argument is deprecated
          Entering stage Checkout
          Proceeding
          [Pipeline] checkout
          Cloning the remote Git repository
          Cloning repository https://github.com/cloudbeers/jenkins-37028.git
           > git init /home/jenkins/workspace/beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q # timeout=10
          Fetching upstream changes from https://github.com/cloudbeers/jenkins-37028.git
           > git --version # timeout=10
          using GIT_ASKPASS to set credentials GitHub Personal Access Token
           > git fetch --tags --progress https://github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/*
           > git config remote.origin.url https://github.com/cloudbeers/jenkins-37028.git # timeout=10
           > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
           > git config remote.origin.url https://github.com/cloudbeers/jenkins-37028.git # timeout=10
          Fetching upstream changes from https://github.com/cloudbeers/jenkins-37028.git
          using GIT_ASKPASS to set credentials GitHub Personal Access Token
           > git fetch --tags --progress https://github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/*
           > git config remote.origin1.url https://github.com/cloudbeers/jenkins-37028.git # timeout=10
          Fetching upstream changes from https://github.com/cloudbeers/jenkins-37028.git
          using GIT_ASKPASS to set credentials GitHub Personal Access Token
           > git fetch --tags --progress https://github.com/cloudbeers/jenkins-37028.git +refs/pull/*/head:refs/remotes/origin/pr/*
          Checking out Revision 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6 (feature)
           > git config core.sparsecheckout # timeout=10
           > git checkout -f 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6
          [Pipeline] sh
          [beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q] Running shell script
          + set -x
          + [ -d .git ]
          + echo checkout done
          checkout done
          + exit 0
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          
          GitHub has been notified of this commit’s build result
          
          Finished: SUCCESS
          
          stephenconnolly Stephen Connolly added a comment - https://jenkins.one-dash.com/job/cloudbeers/job/jenkins-37028/job/feature/1/console Branch event Connecting to https: //api.github.com using stephenc/****** (GitHub Personal Access Token) Cloning the remote Git repository Cloning repository https: //github.com/cloudbeers/jenkins-37028.git > git init / var /jenkins_home/workspace/beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q@script # timeout=10 Fetching upstream changes from https: //github.com/cloudbeers/jenkins-37028.git > git --version # timeout=10 using GIT_ASKPASS to set credentials GitHub Personal Access Token > git fetch --tags --progress https: //github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin.url https: //github.com/cloudbeers/jenkins-37028.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url https: //github.com/cloudbeers/jenkins-37028.git # timeout=10 Fetching upstream changes from https: //github.com/cloudbeers/jenkins-37028.git using GIT_ASKPASS to set credentials GitHub Personal Access Token > git fetch --tags --progress https: //github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin1.url https: //github.com/cloudbeers/jenkins-37028.git # timeout=10 Fetching upstream changes from https: //github.com/cloudbeers/jenkins-37028.git using GIT_ASKPASS to set credentials GitHub Personal Access Token > git fetch --tags --progress https: //github.com/cloudbeers/jenkins-37028.git +refs/pull/*/head:refs/remotes/origin/pr/* Checking out Revision 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6 (feature) > git config core.sparsecheckout # timeout=10 > git checkout -f 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6 First time build. Skipping changelog. [Pipeline] node Running on agent-2 in /home/jenkins/workspace/beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q [Pipeline] { [Pipeline] stage (Checkout) Using the ‘stage’ step without a block argument is deprecated Entering stage Checkout Proceeding [Pipeline] checkout Cloning the remote Git repository Cloning repository https: //github.com/cloudbeers/jenkins-37028.git > git init /home/jenkins/workspace/beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q # timeout=10 Fetching upstream changes from https: //github.com/cloudbeers/jenkins-37028.git > git --version # timeout=10 using GIT_ASKPASS to set credentials GitHub Personal Access Token > git fetch --tags --progress https: //github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin.url https: //github.com/cloudbeers/jenkins-37028.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 > git config remote.origin.url https: //github.com/cloudbeers/jenkins-37028.git # timeout=10 Fetching upstream changes from https: //github.com/cloudbeers/jenkins-37028.git using GIT_ASKPASS to set credentials GitHub Personal Access Token > git fetch --tags --progress https: //github.com/cloudbeers/jenkins-37028.git +refs/heads/*:refs/remotes/origin/* > git config remote.origin1.url https: //github.com/cloudbeers/jenkins-37028.git # timeout=10 Fetching upstream changes from https: //github.com/cloudbeers/jenkins-37028.git using GIT_ASKPASS to set credentials GitHub Personal Access Token > git fetch --tags --progress https: //github.com/cloudbeers/jenkins-37028.git +refs/pull/*/head:refs/remotes/origin/pr/* Checking out Revision 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6 (feature) > git config core.sparsecheckout # timeout=10 > git checkout -f 02bff10ef9fed1ff6c0a0c0ba02109aa5bbeaba6 [Pipeline] sh [beers_jenkins-37028_feature-3F266VKTKXZNXNEQRKR4NCTFRODKTPYHZKABWYR4QVAUOTKIQV6Q] Running shell script + set -x + [ -d .git ] + echo checkout done checkout done + exit 0 [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline GitHub has been notified of this commit’s build result Finished: SUCCESS

          People

            Unassigned Unassigned
            flow86 Florian Doersch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: