Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab CI Start job manually (deployment)

Tags:

Is it possible to mark gitlab ci jobs to start manually?

I need it for deploying application but I want to decide if it's going to be deployed

like image 933
Pekarcik Patrick Avatar asked Apr 16 '16 11:04

Pekarcik Patrick


People also ask

How do I trigger a job in GitLab?

GitLab Setting You can add a new trigger by going to your project's Settings ➔ CI/CD under Triggers. How to get the project ID? going to your project's Settings ➔ General under General project.

What is manual job in GitLab?

In GitLab CI/CD you can easily configure a job to require manual intervention before it runs. The job gets added to the pipeline, but doesn't run until you click the play button on it. Notice that the manual job gets skipped, and the pipeline completes successfully even though the manual job did not get triggered.


2 Answers

This has changed since the first answer has been posted. Here's the link to the original Gitlab Issue. It is now supported to do something like

production:   stage: deploy   script: run-deployment $OMNIBUS_GITLAB_PACKAGE   environment: production   when: manual 

Note the when: manual attribute. The UI updates itself to provide a way for users to trigger the job.

like image 64
MOnsDaR Avatar answered Sep 21 '22 06:09

MOnsDaR


Manually approved build steps are not supported directly afaik. But it should be possible to achieve similar behaviour by using ci triggers.

build_package:   stage: build   script:   - make build  upload_package:   stage: package   script:   - if [ -n "${UPLOAD_TO_S3}" ]; then make upload; fi 

Then you can trigger rebuild by making POST request and passing configured variable.

curl -X POST \   -F token=TOKEN \   -F ref=master \   -F "variables[UPLOAD_TO_S3]=true" \   https://gitlab.example.com/api/v3/projects/9/trigger/builds 

If you have own instance of gitlab it should be possible to inject javascript button on each merge request which will make curl call.

like image 43
Sergii Pechenizkyi Avatar answered Sep 20 '22 06:09

Sergii Pechenizkyi