Skip to content

CI: Enable/Disable jobs based on repo's fork status

Problem

When running a pipeline on forked projects, users would like for some jobs to get skipped (e.g. long tests that already run on the source project)

Proposal

We will introduce a new variable CI_PROJECT_FORK_PATH which will return the forked project path, otherwise it would return null, this way users would be able to control which jobs run and don't run on forks using rules

e.g.

job:
  script: echo "Hello"
  rules:
    - if: $CI_PROJECT_FORK_PATH # this will return the forked project if the current project is a fork

Original proposal

Hi there -

Something we recently started doing internally is having 2 copies of each repo within GitLab - one for the dev team to use, then the testing/QA team will issue merge requests to the production copy of the repo, which uses gitlab-ci.yml to build and deploy code to production. The dev team's repo is a fork of the production repo.

I'd be really useful to state which jobs should be run on which fork. For example, it'd be useful to run automated tests/code quality tests on the dev team's repository when the push to different branches. These tests take some time, though, so I'd rather not run them after accepting a merge request (since they've been run already). And the other side of the coin - when the dev team syncs their repo's master branch from the upstream repo, I don't want any of the deployment jobs to run (we run deployment jobs when commits are pushed to the master branch).

I think there's a few ways to accomplish this - gitlab-ce#18468 would help, but I'd love to have some variable indicating if there's a parent/upstream/source repo.

Edited by Mark Nuzzo