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:

  1. Install the Qovery CLI.
  2. Generate an API token via the CLI or the Console .
  3. Set the environment variable Q_CLI_ACCESS_TOKEN or QOVERY_CLI_ACCESS_TOKEN (both are valid) with your API token. E.g. export QOVERY_CLI_ACCESS_TOKEN=your-api-token
  4. You have turned off the Qovery Auto Deployment for every service that you want to deploy manually.

GitLab CI Examples

Deploy a container application

This example will deploy a container application with Qovery from your GitLab CI pipeline. Feel free to adapt it to your need.

.gitlab-ci.yml
# 1. Build and Push image to a remote registry
# 2. Deploy with Qovery
stages:
- build-and-push
- deploy
build-and-push-image:
stage: build-and-push
script:
- 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_SHA
deploy-image-with-qovery:
stage: deploy
script:
- 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 argument
qovery 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 argument
qovery 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 argument
qovery 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 environment
qovery 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 branch
qovery 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 environment
qovery 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.