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
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
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.
GitLab 13.5 (October 2020) adds more to the when: manual
feature, to support trigger
:
Trigger downstream or child pipelines with manual jobs
Previously, it was not possible to configure a trigger job to wait on a manual action. This made it challenging to configure either downstream or child pipeline triggers to wait for a user to click on them before running.
In this release, we’ve added the ability to add
when: manual
to trigger jobs. Use this keyword to make trigger jobs wait until you click on the play button. This gives you more control of your downstream and child pipelines, and they will only run when you want them to.See Documentation and Issue.
GitLab 14.8 (February 2022) adds another option/approach:
Deployment approval API
We are excited to introduce deployment approval via API.
Prior to this feature, teams had the ability to protect an environment from any changes by requiring a manual job to be executed in a pipeline as a workaround.
< Now, deployment approval is a first-class concept in our platform.
Teams can configure a number of approvers for a specific environment and use a new API endpoint to execute an approval or rejection of a deployment to that environment.
This capability enables teams to create workflows to obtain the proper approvals before deploying software to production or other protected environments.
See Documentation and Issue.
So:
curl --header 'Content-Type: application/json' --request POST \
--data '{"name": "production", "deploy_access_levels": [{"group_id": 9899826}], "required_approval_count": 1}' \
--header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.example.com/api/v4/projects/22034114/protected_environments"
GitLab 15.7 (December 2022) adds:
Retry a manual job with updated variables
When running manual jobs, users can specify the extra CI/CD variables to use in the job.
However, if you wanted to retry the same job, you always had to use the same variables as the first time.
If you wanted to run the job with different variables, you had to run a new pipeline.In this release, we have added the ability to specify variables every time you run a manual job, including when retrying the job.
This allows for greater flexibility and convenience as you can retry a manual job as often as you like with a different set of variables in every run.
See Documentation and Issue.
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.
- triggers
flag in the only
/except
section of a job definition might come handy as it can control whether a job will run only when trigger is used/not used. –
Kicksorter © 2022 - 2024 — McMap. All rights reserved.