Create a CI/CD pipeline
1
Create a CI/CD pipeline
- In the GitLab UI, open your repository. In the left menu, select Build > Pipeline editor.
-
Click Configure pipeline to be guided through creating a
.gitlab-ci.ymlfile to add to your repository to orchestrate the pipeline. The edit section shows a skeleton pipeline that you can configure. You can use this example CI/CD pipeline as a starting point:
-
stagesdefines the order of the jobs in a pipeline. A job has to finish successfully before the next one starts. -
variablesdefines configuration data to authenticate to CDF.CONTAINER_IMAGEdefines the version of the Cognite Toolkit to use for the jobs.
build_modules, deploy_dry_run and deploy_to_cdf.-
Use
stageto define the name of the job. -
Use
scriptto pass the code to run during the job. -
Within the build job, the
artifactssection defines where build files are stored. Go to Build > Artifacts to see previous artifacts. -
For deployment jobs (for example,
deploy_dry_run), include adependenciessection. The deployment jobs depend on output from the previous job. -
The
rulessection lists all rules for the job. In this example configuration, the rules are identical forbuildanddeploy_dry_run, so these jobs run on push to any branch.deploy_to_cdfrun only on pushes to main branch. -
Use the
retrysection to define how many retry attempts to allow on failure. 2 is the maximum.
- Commit your
.gitlab-ci.ymlfile to a branch. The jobs will fail until you finish the setup in the next section.
Create variables for running the pipeline
1
Create variables for running the pipeline
- In the left-hand menu of your project, navigate to Settings > CI/CD.
- Select Variables.
-
In empty table in the Project variables section, use the Add variable button to enter these variables with the correct values for your environment:
- CDF_CLUSTER
- CDF_PROJECT
- CDF_URL
- IDP_CLIENT_ID
- IDP_CLIENT_SECRET (Visibility > “Masked and hidden”)
- IDP_TENANT_ID
-
Important: Hide the
IDP_CLIENT_SECRETvalue. Visibility for other variables can normally be set to “Visible.”
Confirm that the pipeline runs as expected
1
Confirm that the pipeline runs as expected
To check that the setup is successful, push a small change to a branch other than main. Follow the progress of your pipeline in Build > Pipelines.