GitLab Template
This guide shows how to utilize Descope's GitLab CI/CD template to facilitate a smoother transition of resources from development projects to production environments.
Prerequisites
Before you begin utilizing the GitLab CI/CD template, you will need to have a few items outlined below.
- The Descope project IDs for both your development/sandbox and production environments. Essentially, you will need the project IDs for the project you are exporting from and the project you are importing to. These can be found on the Project settings page of the console.
- A management key created on the Company Settings page of the console. When scoping the management key, ensure it has access to both projects you are exporting/importing from/to.
For this guide, we'll be using the projects referenced below.
Using the CI/CD Template
-
Create a new repository in GitLab.
-
Navigate to Descope's GitLab CI/CD Template within GitHub.
-
In order to use the template, all you need to worry about is the
.gitlab-ci.yml
file - copy it over to your new GitLab repository.
Configure Variables and Secrets
-
Once the repository has been created, you need to create a GitLab Project Access Token, as shown in the GitLab guide
-
After creating the Project Access Token, you must add the project IDs and management key to the CI/CD variables section of the GitLab repository. This can be done by clicking into the repository's settings, then going to CI/CD and expanding the Variables section:
GITHUB_PUSH_TOKEN
- the Project Access Token created in the previous step.MANAGEMENT_KEY
- the Management Key created in the Company Settings page.PRODUCTION_PROJECT_ID
- the Project ID of the Descope project you are importing to.STAGING_PROJECT_ID
- the Project ID of the Descope project you are exporting from.
Usage
- Click Build → Pipeline editor and select Configure pipeline.
- Copy the content of the
.gitlab-ci.yml
file from the template to the text editor and commit the change.
-
A
validate_and_deploy
job will automatically run without changes. At first, the repository will be empty (Except the.gitlab-ci.yml
file). We'll want to get the current state of the Descope project into the repository. -
Go to Build → Pipelines in your GitLab project.
-
Select New pipeline → Select main branch → New pipeline.
- Click the ▶️ play button next to export_and_create_mr.
- After a short while, a new Merge Request will be created.
- You can confirm that the added files contain your staging project's settings and configurations.
- Approve and merge the Merge Request to trigger an automatic deployment into your production project.