How to rerun one job with new commit?

We have Gitlab CI pipeline (with several stages and dozen of jobs) that create our AWS environment and at the end start integration test. Building whole environment took very long around one hour.
Sometime happens that error is rised in integration test (last job in our pipeline), after fixing test we have to rerun whole pipeline what take one hour!
Is it possible to rerun one job but with new commit?

Hi @michal_szymanski

It’s possible if you can think of a rule that would skip the first N stages. I guess one possibility would be to write a script that would use git and the GitLab API to figure out whether the last pipeline passed except for its integration test, then iterate over the commits that were pushed since then and look for some string in the commit messages (e.g. FIX_INTEGRATION_TEST) and then skip most of the stages if both those things are true.

Checking the commit messages means you avoid skipping the pipeline when a developer pushes new commits that have nothing to do with fixing the integration test, even though that stage failed last time.

However, I’d suggest that whatever you try to do here will necessarily be quite brittle, and the easier thing would be to shift your integration tests to an earlier stage in the pipeline, if that’s at all possible.

1 Like