Routhinator
Routhinator

Reputation: 3809

How do I establish manual stages in Gitlab CI?

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?

Upvotes: 47

Views: 88343

Answers (4)

Andrey Usov
Andrey Usov

Reputation: 1587

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

Upvotes: 5

Jorge Beatty
Jorge Beatty

Reputation: 11

stages:
  - deploy_dev
  - deploy_test
  - release
deploy_dev:
  stage: deploy_dev
  script:
    - echo "Deploying to Dev environment..."
    - ./deploy_to_dev.sh #deployment script
  only:
    - master
deploy_test:
  stage: deploy_test
  script:
    - echo "Deploying to Test environment..."
    - ./deploy_to_test.sh #deployment script
  when: manual
  only:
    - master

Upvotes: 0

LondonAppDev
LondonAppDev

Reputation: 9633

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.

Upvotes: 66

Snorre
Snorre

Reputation: 333

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.

Upvotes: 10

Related Questions