Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-13977

When using a default branch other than "master", ref must be specified for GitHub trigger to work

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • 4.13.0
    • Build
    • None
    • Low
    • No
    • Pipeline Integrations #238, Pipeline Integrations #239, Pipeline Integrations #240, Pipeline Integrations #241, Pipeline Integrations #242, Pipeline Integrations #243
    • 6
    • False
    • Hide

      None

      Show
      None

      Description of problem:

      I created a BuildConfig for a repo that uses "main" as the branch name.  My config looked like this:
      
        source:
          type: Git
          git:
            uri: 'https://github.com/openshift-eng/ci-test-mapping'
        triggers:
          - type: ConfigChange
          - type: GitHub
            github:
              secretReference:
                name: github-webhook-secret
      
      The GitHub webhooks were not triggering builds, and after digging in, I had to specify ref in the source:
      
        source:
          type: Git
          git:
            uri: 'https://github.com/openshift-eng/ci-test-mapping'
            ref: main
      
      Would it be possible to make this easier for a user? It's possible to determine the default branch after cloning so perhaps this could be stored in the BuildConfig status.
      
      It wasn't clear to me the "ref" was used in the webhook payload, but GitHub sends something like this:
      
      {
        "action"      : "push",
        "pusher"      : { "email" : "my@email.com" },
        "ref"         : "refs/heads/main"
      }
      
      
      
      

      Version-Release number of selected component (if applicable):

      
      

      How reproducible:

      
      

      Steps to Reproduce:

      1. Create a BuildConfig for a git repo without a master default branch, and add a GitHub trigger
      2. Leave off the ref in the source
      3. Push to GitHub
      

      Actual results:

      No build gets triggered
      

      Expected results:

      Build gets triggered
      

      Additional info:

      If the behavior can't be changed perhaps just the docs could be updated?
      
      https://docs.openshift.com/container-platform/4.13/cicd/builds/creating-build-inputs.html#builds-source-code_creating-build-inputs
      
      says "Optionally, specify the ref field to check out a specific Git reference." Perhaps it should mention it's only optional if the default branch is master.
      
      And https://docs.openshift.com/container-platform/4.13/cicd/builds/triggering-builds-build-hooks.html#builds-using-github-webhooks_triggering-builds-build-hooks should show an example of the payload GitHub sends, and mention the ref field is relevant. i.e., the build will only be triggered in the ref from the github webhook event matches the ref in the git source
      

              rh-ee-apjagtap Apoorva Jagtap
              stbenjam Stephen Benjamin
              Corey Daley Corey Daley
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: