Skip to content

Add file matching rule to flexible rules

Problem to solve

Currently it's not possible to evaluate a project's contents and use only or except logic before running a pipeline. This means that Auto DevOps pipelines run even when they won't add any value (for example on projects using a language with no matching buildpack or projects that host no code).

Intended users

developers

Further details

Proposal

In order to use the same mechanism Auto DevOps uses to detect a project's language (herokuish+buildpacks) and evaluate contents of a project before running a pipeline, a new flexible rule to GitLab CI so that it may look for files or directories in the relevant project. This rule will be similar to changes. This will allow us to Not run Auto DevOps when no dockerfile or matching buildpack exists

I would like to be able to do something like the following for auto devops:

build_dockerfile:
  script:
  - docker build
  rules:
    - local:
      - Dockerfile

build_herokuish:
  script:
  - docker run herokuish
  rules:
  - local:
    - Dockerfile
    when: never
  - if: '$KUBECONFIG'

Or in general we could do other things like:

rake:
  image: ruby
  script:
  - bundle install
  - bundle exec rake
  rules:
  - local:
    - Rakefile

which could replace the herokuish logic for build/test and in theory will be much more performant because it is able to cache the build images. Furthermore it allows us to customise the steps for each language a lot more easily.

Documentation

Testing

What does success look like, and how can we measure that?

TBD

Links / references

https://gitlab.com/gitlab-org/gitlab-ce/issues/57483

Edited by James Fargher