[go: up one dir, main page]

GitLab

This walkthrough shows you how to use CloudTruth parameters with GitLab CI /CD jobs.

Prerequisites

Provide GitLab Access

Add your generated CloudTruth API Access token as a GitLab variable called CLOUDTRUTH_API_KEY in your project settings. This allows the GitLab project to securely access parameters stored in CloudTruth.

Configure a CI/CD pipeline with CloudTruth Parameters

Install the CloudTruth CLI with a Build Stage

You can install the CLI with the following code snippet in a GitLab build stage. This will install the latest supported version and also verify the CLI is installed correctly by printing the version.

Passing CloudTruth parameters to GitLab test stages

In the build stage, we can access and pass variables to GitLab with artifacts. This snippet will add environment variables FLASK RUN PORT and FLASK_MESSAGE to build.env with values pulled from CloudTruth.

Using CloudTruth parameters in test stages

Now you can reference the variables in downstream stages.

Running this pipeline will install the CloudTruth CLI and print the parameter values.

The complete .gitlab-ci.yml

Parameter export

Alternatively you can use the CloudTruth parameter export command to create a GitLab .env file. GitLab pipelines will fail to upload a .env file if it has a newline at the end of the file. We will use a sed command in the job to strip the export of empty lines.

sed -i '/^$/d' build.env

Last updated

Was this helpful?