I have two jobs in GitLab CI/CD: build-job (which takes ~10 minutes) and deploy-job (which takes ~2 minutes). In a pipeline, build-job succeeded while deploy-job failed because of a typo in the script. How can I fix this typo and run only deploy-job, instead of rerunning build-job?
My current .gitlab-ci.yml is as follows:
stages:
- build
- deploy
build-job:
image: ...
stage: build
only:
refs:
- main
changes:
- .gitlab-ci.yml
- pubspec.yaml
- test/**/*
- lib/**/*
script:
- ...
artifacts:
paths:
- ...
expire_in: 1 hour
deploy-job:
image: ...
stage: deploy
dependencies:
- build-job
only:
refs:
- main
changes:
- .gitlab-ci.yml
- pubspec.yaml
- test/**/*
- lib/**/*
script:
- ...
I imagine something like:
- the triggerer (me) fixes the typo in
deploy-job's script and pushes the changes - the pipeline is triggered
- the runner looks at the files described by
build-job/only/changesand detects a single change in the .gitlab-ci.yml file - the runner looks at the .gitlab-ci.yml file and detects there IS a change, but since this change does not belong to the
build-jobsection AND the job previously succeeded, this job is skipped - the runner looks at the files described by
deploy-job/only/changesand detects a single change in the .gitlab-ci.yml file - the runner looks at the .gitlab-ci.yml file and detects there is a change, and since this change belongs to the
deploy-jobsection, this job is executed
This way, only deploy-job is executed. Can this be done, either using rules or only?