How do I establish manual stages in Gitlab CI?

Routhinator picture Routhinator · Aug 9, 2015 · Viewed 17.9k times · Source

I'd can't seem to find any documentation of manual staging in Gitlab CI in version 8.9. How do I do a manual stage such as "Deploy to Test"?

I'd like Gitlab CI to deploy a successful RPM to dev, and then once I've reviewed it, push to Test, and from there generate a release. Is this possible with Gitlab CI currently?

Answer

LondonAppDev picture LondonAppDev · Dec 12, 2018

You can set tasks to be manual by using when: manual in the job (documentation).

So for example, if you want to want the deployment to happen at every push but give the option to manually tear down the infrastructure, this is how you would do it:

stages:
  - deploy
  - destroy

deploy:
  stage: deploy
  script:
    - [STEPS TO DEPLOY]

destroy:
  stage: destroy
  script:
    - [STEPS TO DESTROY]
  when: manual

With the above config, if you go to the GitLab project > Pipelines, you should see a play button next to the last commit. When you click the play button you can see the destroy option.