Skip to content

PoC: Run fork MR/PR pipeliens in parent project

Shinya Maeda requested to merge poc-run-pipelines-in-parent into master

What does this MR do?

Fork users can create pipelines in a parent project, if it fulfills all of the following conditions:

  • The option "Allow fork merge request (or pull request) to run pipelines in the parent project" is enabled in the parent project. This option is off by default.
  • MR/PR has already been created in the parent project. If it doesn't exist, pipelines are not created even if user pushed a branch in a fork repo. i.e. branch pipelines are not supported.
  • The parent/fork projects are public. Private repos are not supported for now.

Process flow overview

Internal Merge requests https://gitlab.com/gitlab-org/gitlab-ee/issues/11934

  1. The parent project enables "Allow fork merge request (or pull request) to run pipelines in parent project" option.
  2. An external user creates/updates a merge request from a forked repo.
  3. MergeRequests::Create/UpdateService runs, which triggers MergeRequests::CreatePipelineService
  4. The pipeline is created on parent project. This pipeline runs on refs/head or refs/merge in parent project.
  5. Runners in the parent project execute the jobs.

External Pull requests https://gitlab.com/gitlab-org/gitlab-ce/issues/65139

  1. User created CI/CD only project from the parent project in GitHub
  2. The parent project enables "Allow fork merge request (or pull request) to run pipelines in parent project" option.
  3. An external user creates/updates a pull request from a forked repo.
  4. created/synchronize events are notified via PullRequestWebhook to GitLab. ProcessGithubPullRequestEventService is executed and SyncGitHubRefWorker runs.
  5. ExternalPullRequests::FetchRefService fetches PR specific refs refs/head (or mirroring) from the parent projects.
  6. ExternalPullRequests::CreatePipelineService creates a pipeline on the fetched ref.
  7. Runners in the parent project execute the jobs.

TODO:

  • Fork MR can create pipelines in parent
  • Fork PR can create pipelines in parent

This MR is functional at this moment.

screenshot_23

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Shinya Maeda

Merge request reports