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

Unable to build origin PRs with GitHub Branch Source Plugin: Couldn't find any revision to build

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Incomplete
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      I have created a freestyle multi-branch project, and I've configured it to use the GitHub branch source plugin as shown on the attached screenshot. With this I am unable to build origin pull requests (from the same repo). All builds fail with the message in the log below.

      How to reproduce:

      1. Start a clean Jenkins installation, possibly in a Docker container
      2. Install the github-branch-source-plugin and the multi-branch-project-plugin, possibly using install-plugins.sh multi-branch-project-plugin github-branch-source
      3. Add access credentials of the type Username with password using my predefined user with username jenkins-37144 and password 37144-jenkins. That is a GitHub user which has a repository with an open pull request.
      4. Create a Freestyle multi-branch project:
        1. Under Branch Sources, add GitHub as a source
        2. Configure jenkins-37144 as the owner
        3. Select the credentials from above
        4. Select jenkins-pr-test-repo as the repository
        5. Click Advanced... and make sure Build origin PRs (merged with base branch) is checked.
      5. Run the branch indexing for the job
      6. Run the job for the pull request and watch it fail with the error described below

      The build fails with this in the log:

       > git rev-parse origin/PR-27^{commit} # timeout=10
       > git rev-parse origin1/PR-27^{commit} # timeout=10
       > git rev-parse PR-27^{commit} # timeout=10
      ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
      Finished: FAILURE
      

      When running the same git commands manually, they fail as well, but providing origin/PR/27 instead of origin/PR-27 works:

      > git rev-parse origin/PR-27^{commit}
      fatal: ambiguous argument 'origin/PR-27^{commit}': unknown revision or path not in the working tree.
      > git rev-parse origin/PR/27^{commit}
      0bbc328a72b6083d593c1ae746f80fdba75aa61a
      

      Good to know:

      • All "non-PR" builds work fine.
      • Everything outside of the screenshot is configured according to the defaults.
      • The pull request exists and has no conflicts with the base branch.
      • The GitHub repository is my organization's private repository.
      • Builds are triggered by branch indexing.

        Attachments

          Activity

          Hide
          racermike Mike Neary added a comment -

          Thank you Jesse Glick.  With a little reorganizing of my Jenkinsfile and using 'checkout scm' I was able to get all builds working, including PRs.

          Show
          racermike Mike Neary added a comment - Thank you Jesse Glick .  With a little reorganizing of my Jenkinsfile and using 'checkout scm' I was able to get all builds working, including PRs.
          Hide
          mjdetullio Matthew DeTullio added a comment -

          I wasn't able to identify any parts of the multi-branch-project-plugin that would affect the Git branch spec.  The SCM/BranchSource plugin(s?) are responsible for providing a Branch with an SCMHead set to the proper spec and also responsible for generating an SCM from that information.  The multi-branch-project-plugin simply persists (for each sub-project) the SCM configuration it is provided.

          Show
          mjdetullio Matthew DeTullio added a comment - I wasn't able to identify any parts of the multi-branch-project-plugin that would affect the Git branch spec.  The SCM/BranchSource plugin(s?) are responsible for providing a Branch with an SCMHead set to the proper spec and also responsible for generating an SCM from that information.  The multi-branch-project-plugin simply persists (for each sub-project) the SCM configuration it is provided.
          Hide
          jrawlings James Rawlings added a comment -

          I'm having a similar issue when using the github org plugin.  Master builds work great as well as Jobs triggered by PRs that come from a fork, however if I create a branch in the same repo and make a pull request to the master branch I get the same error:

          OpenShift Build rhn-support-jrawling/jr-demo99.pr-3-2 from https://github.com/rawlingsj/jr-demo99.git
           > git rev-parse --is-inside-work-tree # timeout=10
          Fetching changes from the remote Git repository
           > git config remote.origin.url https://github.com/rawlingsj/jr-demo99.git # timeout=10
          Fetching upstream changes from https://github.com/rawlingsj/jr-demo99.git
           > git --version # timeout=10
           > git fetch --tags --progress https://github.com/rawlingsj/jr-demo99.git +refs/heads/*:refs/remotes/origin/*
           > git rev-parse origin/PR-3^{commit} # timeout=10
           > git rev-parse PR-3^{commit} # timeout=10
          ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
          Finished: FAILURE 
          
          

          A bit of googling a similar issue suggests the refspec for the PR job config might need to include the /pr/

          +refs/pull/*:refs/remotes/origin/pr/*
          

          If I'm not missing anything and this is in fact a problem + a feasible solution, could someone point me at the code which creates the Job config so I can try a fix?

          Show
          jrawlings James Rawlings added a comment - I'm having a similar issue when using the github org plugin.  Master builds work great as well as Jobs triggered by PRs that come from a fork, however if I create a branch in the same repo and make a pull request to the master branch I get the same error: OpenShift Build rhn-support-jrawling/jr-demo99.pr-3-2 from https: //github.com/rawlingsj/jr-demo99.git > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url https: //github.com/rawlingsj/jr-demo99.git # timeout=10 Fetching upstream changes from https: //github.com/rawlingsj/jr-demo99.git > git --version # timeout=10 > git fetch --tags --progress https: //github.com/rawlingsj/jr-demo99.git +refs/heads/*:refs/remotes/origin/* > git rev-parse origin/PR-3^{commit} # timeout=10 > git rev-parse PR-3^{commit} # timeout=10 ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. Finished: FAILURE  A bit of googling a similar issue suggests the refspec for the PR job config might need to include the /pr/ +refs/pull/*:refs/remotes/origin/pr/* If I'm not missing anything and this is in fact a problem + a feasible solution, could someone point me at the code which creates the Job config so I can try a fix?
          Hide
          stephenconnolly Stephen Connolly added a comment -

          is this fixed by JENKINS-43507?

          Show
          stephenconnolly Stephen Connolly added a comment - is this fixed by JENKINS-43507 ?
          Hide
          stephenconnolly Stephen Connolly added a comment -

          No feedback in over two months, assuming fixed by JENKINS-43507 unless we hear otherwise

          Show
          stephenconnolly Stephen Connolly added a comment - No feedback in over two months, assuming fixed by JENKINS-43507 unless we hear otherwise

            People

            • Assignee:
              Unassigned
              Reporter:
              davidparsson David Pärsson
            • Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: