Skip to content

WIP: [RFC] Add complex policy paths to gitlab-ci

Ashwini Dhekane requested to merge ashwinikd/gitlab-ce:ci-policy-paths into master

What does this MR do?

This is an RFC for a solution to #19232 (closed). This is not ready to be merged yet. This MR adds paths complex policy for CI jobs. It allows running jobs only when changed files match given blobs. Example use:

build:
  ...
  only:
    paths:
      - src/**
      - Makefile

This checks the file changes for following cases:

  1. If pipeline is running against a merge request all the files changed between branch merge base and merge request diff head are included.
  2. If pipeline is running for the first time on branch all files in project at head are included.
  3. All file changes in current push (multi commit) are included.

It uses File.fnmatch to match the glob to file names.

Are there points in the code the reviewer needs to double check?

I am not familiar with the gitlab internals. I am not sure if my way of finding the file changes is the best way. There might be corner case that this might miss. Though the code has been tested on local dev install and it works.

  • Use of before_sha in pipeline.
  • Performance implications of ls_files.

Why was this MR needed?

This attempts to resolve #19232 (closed).

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

#19232 (closed)

Edited by Ashwini Dhekane

Merge request reports