patternyamlMinor
Gitlab: Always having the possibility to launch a manual job (even if something failed before)
Viewed 0 times
thebeforegitlabalwayshavingmanualfailedpossibilityevenlaunch
Problem
I'm using gitlab-ci. I have a pipeline that has the following steps :
-
code-verification
-
some tests
-
deploy (manual)
-
some more tests
-
rollback (manual)
Both the deploy and the rollback job have to be launch manually which means that I'm using
However, I also want the rollback to be possible even if a step/job has fail before (for example, a faulty deploy or a failing in the "some more tests" stage).
I was thinking of using
For now, I just put the "some more tests" and the "rollback" in the same stage so that the failure of one doesn't impact the other. But is there another way to do this?
I really wish to have everything in the same pipeline (so no trigger) and to always have the possibility to launch the rollback job. No matter what happened before.
-
code-verification
-
some tests
-
deploy (manual)
-
some more tests
-
rollback (manual)
Both the deploy and the rollback job have to be launch manually which means that I'm using
when: manual in my gitlab-ci.yml file.However, I also want the rollback to be possible even if a step/job has fail before (for example, a faulty deploy or a failing in the "some more tests" stage).
I was thinking of using
when: always but since I'm already using the when: manual, it doesn't work (I tried).For now, I just put the "some more tests" and the "rollback" in the same stage so that the failure of one doesn't impact the other. But is there another way to do this?
I really wish to have everything in the same pipeline (so no trigger) and to always have the possibility to launch the rollback job. No matter what happened before.
Solution
You can use
Example:
For more example: https://docs.gitlab.com/ee/ci/yaml/#when
when: on_failure, in your case you can create a new job for rollback when your some more tests have failed.Example:
cleanup_build_job:
stage: cleanup_build
script:
- cleanup build when failed
when: on_failure
For more example: https://docs.gitlab.com/ee/ci/yaml/#when
Context
StackExchange DevOps Q#11897, answer score: 2
Revisions (0)
No revisions yet.