Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to skip a pipeline when there are markdown changes only?

Goal

The release pipeline should start a deployment for specific branches.
This should not happen (skip the job), if there are only documentation changes. (*.md files)

The problem

If you change multiple files, but only one file ends in .md, the build job is still skipped. The job does not run for any of the files.

https://docs.gitlab.com/ee/ci/jobs/job_control.html#onlychanges--exceptchanges-examples

So, is it even possible to specifcy a rule as mentioned above?

What I tried so far (an excerpt)

So, if "*.md" doesn't work, is it possible to revert it?
"**/!(*.md)" # Every file except *.md

This does not execute anything

  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      changes:
      - "**/!(*.md)" # Every file except *.md

This executes always

  rules:
    - if: $CI_COMMIT_BRANCH == "main"
    - changes:
      - "**/!(*.md)"

Question

Do I have to use custom variables to solve this problem or is there a simpler way?

like image 549
kapsiR Avatar asked Jan 25 '26 08:01

kapsiR


2 Answers

After contacting the GitLab Support, I can document here, that there is no way of doing that currently.

A new issue has been created for this specific use case:
https://gitlab.com/gitlab-org/gitlab/-/issues/198688

like image 88
kapsiR Avatar answered Jan 27 '26 01:01

kapsiR


Below is the more elegant solution and is documented on the GitLab docs.

So there are two approaches.

  1. To push a commit without triggering a pipeline, add [ci skip] or [skip ci], using any capitalization, to your commit message.

  2. Alternatively, if you are using Git 2.10 or later, use the ci.skip Git push option. The ci.skip push option does not skip merge request pipelines.

    git push --push-option=ci.skip for GL version 2.18 and later, even the short version

    git push -o ci.skip

Reference:

  • https://docs.gitlab.com/ee/ci/pipelines/index.html#skip-a-pipeline
  • https://docs.gitlab.com/ee/user/project/push_options.html
like image 30
Sanjay Bharwani Avatar answered Jan 27 '26 00:01

Sanjay Bharwani