GitLab CI
Using Gitlab CI with Qovery is super powerful and gives you the ability to manage the way that you want to deploy your applications. As the possibility are endless, I will share with you a couple of examples that you can use. Feel free to adapt them to your need.
Prerequisites
Before using the examples below, you need to:
- Install the Qovery CLI.
- Generate an API token via the CLI or the Console .
- Set the environment variable
Q_CLI_ACCESS_TOKEN
orQOVERY_CLI_ACCESS_TOKEN
(both are valid) with your API token. E.g.export QOVERY_CLI_ACCESS_TOKEN=your-api-token
- You have turned off the Qovery Auto Deployment for every service that you want to deploy manually.
GitLab CI Examples
Deploy a container application
Before you begin, this page assumes the following:
- You have connected your Container Registry with Qovery.
- You have a container application that you want to deploy on Qovery.
- You have set the
QOVERY_CLI_ACCESS_TOKEN
environment variable in your GitLab CI project.
This example will deploy a container application with Qovery from your GitLab CI pipeline. Feel free to adapt it to your need.
# 1. Build and Push image to a remote registry# 2. Deploy with Qoverystages:- build-and-push- deploybuild-and-push-image:stage: build-and-pushscript:- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY- docker build . --tag my-registry-group/your-app:$CI_COMMIT_SHORT_SHA- docker push my-registry-group/your-app:$CI_COMMIT_SHORT_SHAdeploy-image-with-qovery:stage: deployscript:- curl -s https://get.qovery.com | bash # Download and install Qovery CLI- |qovery container deploy \--organization <your_org_name> \--project <your_project_name> \--environment <your_environment_name> \--container <your_qovery_container_name> \--tag $CI_COMMIT_SHORT_SHA \--watch
Qovery CLI command examples
Deploy your application with a specific commit ID
qovery application deploy \--organization <your_org_name> \--project <your_project_name> \--environment <your_environment_name> \--application <your_app_name> \--commit-id <your_commit_id> \--watch
Deploy your multiple applications with a different commit ID
# deploy the application 1 and wait for the deployment to be successful with the --watch argumentqovery application deploy \--organization <your_org_name> \--project <your_project_name> \--environment <your_environment_name> \--application <your_app_1_name> \--commit-id <your_commit_id> \--watch# deploy the application 2 and wait for the deployment to be successful with the --watch argumentqovery application deploy \--organization <your_org_name> \--project <your_project_name> \--environment <your_environment_name> \--application <your_app_2_name> \--commit-id <your_commit_id> \--watch
This is also applicable for the qovery container deploy
, qovery lifecycle deploy
, and qovery cronjob deploy
commands.
Deploy your multiple applications with a specific commit ID (monorepo)
# deploy the application 1, 2 and 3 with the same commit ID and wait for the deployment to be successful with the --watch argumentqovery application deploy \--organization <your_org_name> \--project <your_project_name> \--environment <your_environment_name> \--applications "<app_1_name>, <app_2_name>, <app_3_name>" \--commit-id <your_commit_id> \--watch
This is also applicable for the qovery container deploy
, qovery lifecycle deploy
, and qovery cronjob deploy
commands.
Create a Preview Environment for your Pull-Request
Qovery integrates automatically with GitHub, GitLab and Bitbucket to create a Preview Environment for each Pull-Request. But in case you want to control the creation of the Preview Environment manually, you can use the following commands:
# Clone your base environmentqovery environment clone \--organization <your_org_name> \--project <your_project_name> \--environment <your_environment_name> \--new-environment-name <your_new_environment_name># Change your application branch to the Pull-Request branchqovery application update \--organization <your_org_name> \--project <your_project_name> \--environment <your_new_environment_name> \--application <your_app_name> \--branch <your_pull_request_branch_name># Deploy your new environmentqovery environment deploy \--organization <your_org_name> \--project <your_project_name> \--environment <your_new_environment_name> \--watch
Delete a Preview Environment
qovery environment delete \--organization <your_org_name> \--project <your_project_name> \--environment <your_preview_environment_name> \--watch
Terraform
Do you want to include Terraform in your CI? Check out our Terraform documentation.
Any other examples?
Feel free to share your examples with us, and we'll be happy to share them with the community. Contact us on our forum.