Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 23
    • Issues 23
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #65139
Closed
Open
Issue created Jul 25, 2019 by Patrick Harlan@pharlan

Support `only/except: merge_requests` for external repos

Problem to solve

GitLab CI has an "external repos" capability intended to allow customers to use GitHub for source control and GitLab CI, however the CI_PIPELINE_SOURCE always shows push because it is based on the pull mirror rather than the source GitHub repo or webhook. This prevents GitLab CI with External Repos from supporting the only/except: merge_requests options.

Intended users

Large projects with a need to separate short running tests from longer running tests. As a customer with a complex CI pipeline, it is common to give developers quick feedback on atomic commits, while having more robust testing patterns run prior to merging to master. This separation of tests needs to be enforced, and can't rely on manual triggering of jobs. The ability to use only/except: merge_requests cases in pipelines is vital to achieving feature parity with competing CI products.

Further details

One customer with these requirements is open to considering workarounds, as long as they meet their ultimate requirement of being able to have separate sets of test run based on the event that triggered the pipeline (commit vs Pull Request). As noted here https://blog.dachary.org/2014/12/01/copy-a-github-pull-request-to-gitlab/ it may be possible to infer a Pull Request from the refs/pull/N/head reference to the base of the pull request in the git repo after the mirror has been refreshed.

Or if we could have GitHub fire different webhooks and GitLab could persist that info long enough to put in a CI variable, then we could achieve similar branching.

Proposal

As implemented in gitlab!15082 (merged):

This issue introduces support for only/except: external_pull_requests when using the project for CI/CD only with a GitHub repository. When using only/except: external_pull_requests we allow jobs to be created for a pipeline if a GitHub pull request is open for the given ref.

When using a mirror for CI/CD only we register a pull_request webhook. When a pull_request webhook is received for the pull request being created, if the repository already contains the SHA related to the pull request, we create immediately a new pipeline. Otherwise we store the pull request info for when changes are pushed to branches. When changes are pushed to branches we check if any pull requests are opened for the given ref and create pipelines for pull requests.

Next follow up is adding support for forks: gitlab#5667

Customers

https://gitlab.my.salesforce.com/00161000013ZvZ0

Edited Sep 17, 2019 by Jason Yavorska
Assignee
Assign to
Time tracking