Reputation: 11486
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:
deploy-job
's script and pushes the changesbuild-job
/only
/changes
and detects a single change in the .gitlab-ci.yml filebuild-job
section AND the job previously succeeded, this job is skippeddeploy-job
/only
/changes
and detects a single change in the .gitlab-ci.yml filedeploy-job
section, this job is executedThis way, only deploy-job
is executed. Can this be done, either using rules
or only
?
Upvotes: 2
Views: 1842
Reputation: 339
There is a straight foward way, you just have to have access to gitlab CI interface.
Another way is to create a new job, intended to be runned only when needed, in which you can set a non-dependency deploy. Just copy the current deploy code without the dependencies. Also add the manual mode with
job:
script: echo "Hello, Rules!"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true
As docs.
Upvotes: 1