How do I establish manual stages in Gitlab CI?

Finally, we have Gitlab CI manual actions that were introduced in GitLab 8.10.


Update: Manual actions were Introduced in GitLab 8.10. From the manual "Manual actions are a special type of job that are not executed automatically; they need to be explicitly started by a user. Manual actions can be started from pipeline, build, environment, and deployment views. You can execute the same manual action multiple times." An example usage of manual actions is deployment to production. The rest of this answer applies to Gitlab 8.9 and older only.

Historical Answer:

It does not appear as though manual deploy/release was available in Gitlab in 8.9.

One possibility is to have a protected branch which triggers a release. See info about protected branches here: http://doc.gitlab.com/ce/workflow/protected_branches.html

Essentially a protected branch would allow you to Create a branch (testdeploybranch) which only you would be allowed to merge code into. Whenever a commit to dev would pass the Gitlab CI tests and deploy jobs, as well as your manual review, you could merge that commit into the protected branch to trigger the release. For this branch you can then set up a special release job in Gitlab CI using the only option in the .gitlab-ci.yml job definition. Read more here: http://doc.gitlab.com/ci/yaml/README.html

So something like this:

release:
  only: testdeploybranch
  type: release
  script: some command or script invocation to deploy to Test

This might not be exactly what you are after, but it does allow you to do manual releases from Gitlab. It does not provide an easy way to manually do the same release procedure manually for different servers. Perhaps someone else might be able to expand on this strategy.


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.