<p>You can use <code>when: on_failure</code>, in your case you can create a new job for rollback when your <code>some more tests</code> have failed.</p>
<h3>Example:</h3>
<pre class="lang-yaml prettyprint-override"><code>cleanup_build_job:
  stage: cleanup_build
  script:
    - cleanup build when failed
  when: on_failure
</code></pre>
<p>For more example: <a href="https://docs.gitlab.com/ee/ci/yaml/#when" rel="nofollow noreferrer">https://docs.gitlab.com/ee/ci/yaml/#when</a></p>

CC BY-SA 4.0
2021-05-06T07:21:29.630Z
That wouldn't work. Because then, it would always launch a rollback if one of my test fail and I don't want that. I want to manually take the decision to rollback or not.
BelovedFool
CC BY-SA 4.0
2021-05-06T07:56:02.963Z
You should add `allow_failure: true` to your other tests and stay on `when: manual` if you want to keep control of the rollback.
Tartan
CC BY-SA 4.0
2021-05-06T09:18:57.503Z
I think that would work indeed. Thanks for the help!
BelovedFool
CC BY-SA 4.0
2021-05-05T21:42:55.267Z
2021-05-05T21:42:55.267Z
Tartan
<p>I'm using gitlab-ci. I have a pipeline that has the following steps :</p>
<ol>
<li><p>code-verification</p>
</li>
<li><p>some tests</p>
</li>
<li><p>deploy (manual)</p>
</li>
<li><p>some more tests</p>
</li>
<li><p>rollback (manual)</p>
</li>
</ol>
<p>Both the deploy and the rollback job have to be launch manually which means that I'm using <code>when: manual</code> in my gitlab-ci.yml file.</p>
<p>However, I also want the rollback to be possible <em>even</em> if a step/job has fail before (for example, a faulty deploy or a failing in the &quot;some more tests&quot; stage).</p>
<p>I was thinking of using <code>when: always</code> but since I'm already using the <code>when: manual</code>, it doesn't work (I tried).</p>
<p>For now, I just put the &quot;some more tests&quot; and the &quot;rollback&quot; in the same stage so that the failure of one doesn't impact the other. But is there another way to do this?</p>
<p>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.</p>

<continuous-integration><gitlab><continuous-deployment><yaml>
Gitlab: Always having the possibility to launch a manual job (even if something failed before)
BelovedFool
# Gitlab: Always having the possibility to launch a manual job (even if something failed before)

(Asked by: username_0 on 2020-06-24)

I'm using gitlab-ci. I have a pipeline that has the following steps :

1. code-verification
2. some tests
3. deploy (manual)
4. some more tests
5. 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.

**Tags:** continuous-integration, gitlab, continuous-deployment, yaml


---

## 1 answers

### Answer by username_1 on 2021-05-05. Score: 2

You can use 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

> **Comments:**
> **username_0**: That wouldn't work. Because then, it would always launch a rollback if one of my test fail and I don't want that. I want to manually take the decision to rollback or not.  
> **username_1**: You should add `allow_failure: true` to your other tests and stay on `when: manual` if you want to keep control of the rollback.  
> **username_0**: I think that would work indeed. Thanks for the help!  

---

