Conditional run of a job - when it failed for a previous push

Hello! I browsed through the doc on CI/CD quite extensively, but couldn’t find a quick solution for the below. I’d appreciate some pointers very much :pray:

We have a MR pipeline job that runs only if any of specified files have been changed.
The situation I want to avoid:
Commit A contains changes of a given file, therefore the job will run after it is pushed. Let’s say it fails.
Commit B is pushed a few hours later, but doesn’t change any of the files in the job’s condition. The step will not run for this push and the pipeline succeeds.

This is then merged and the pipeline on master fails, because we always run the whole pipeline on master, but I’d want to avoid merging such a thing and not having a false-positive pass.

Question: Is it possible to add a condition for a job that references a previous push for a given MR?
“Run if the job failed for the previous push” or “Run the job if the branch contains changes to the file”
The first one would be better, because we’d reduce the number of overall jobs run, but I’ll take any of them :wink:

Thank you so much for pointers and inspiration!

Hi,

Cannot reproduce on GitLab.com. If I have 2 jobs like this

workflow:
    rules:
        - if: $CI_PIPELINE_SOURCE == "merge_request_event"

stages:
    - build

web:
  stage: build
  rules:
    - changes:
        - web/*
  script:
    - echo 'web changed'

proxy:
  stage: build
  rules:
    - changes:
        - proxy/*
  script:
    - echo 'proxy changed'
  1. commit - changing web/file => only web job is run
  2. commit - changing proxy/fileweb and proxy job is run as expected

Example Branch4 (!5) · Merge requests · pjakubis / Rules Changes · GitLab

@_monika, are you using compare_to by any chance? I not, my experience is similar to that of @ balonik.