This documentation is for a release that is no longer maintained
See documentation for the latest supported version.Chapter 2. Adding secrets to GitLab CI for secure integration with external tools
If you select GitLab as your CI provider and create an application, you might notice that the pipeline run fails. This failure occurs because the pipeline cannot find the required GitLab and other secrets. Complete the following procedure to add the necessary secrets and resolve the pipeline failure.
Prerequisites
- You must have the necessary permissions to create and manage GitLab jobs and GitLab CI variables.
- You must have an image registry (for example, Quay.io) username and password for accessing and pull container images.
You must have the following information for specific tasks that you want the GitLab CI to perform:
For ACS tasks:
- ROX Central server endpoint and token
For SBOM tasks:
- Cosign signing keys password, private key, and public key
- Trustification URL, client ID, secret, and supported CycloneDX version
2.1. Adding secrets to GitLab CI using UI Copy linkLink copied to clipboard!
Procedure
- Log in and navigate to your source repository.
- Expand the Setting menu and select CI/CD.
- In the Variables section, select Expand, and then select Add variable.
- Under Flags, select the Mask variable checkbox.
- In the Key field, enter MY_GITLAB_TOKEN.
- In the Value field, enter the token associated with your GitLab account.
Repeat steps 3-6 to add the required variables:
Expand Variable Description Variables required for all pipeline runs
QUAY_IO_CREDS_USRUsername for accessing Quay.io credentials.
QUAY_IO_CREDS_PSWPassword for accessing Quay.io credentials.
REKOR_HOSTURL of your Rekor server.
TUF_MIRRORURL of your TUF service.
Variable required for ACS tasks
ROX_CENTRAL_ENDPOINTEndpoint for the ROX Central server.
ROX_API_TOKENAPI token for accessing the ROX server.
Variables required for SBOM tasks
COSIGN_SECRET_PASSWORDPassword for Cosign signing key.
COSIGN_SECRET_KEYPrivate key for Cosign.
COSIGN_PUBLIC_KEYPublic key for Cosign.
TRUSTIFICATION_BOMBASTIC_API_URLURL for Trustification Bombastic API used in SBOM generation.
TRUSTIFICATION_OIDC_ISSUER_URLOIDC issuer URL used for authentication when interacting with the Trustification Bombastic API.
TRUSTIFICATION_OIDC_CLIENT_IDClient ID for authenticating to the Trustification Bombastic API using OIDC.
TRUSTIFICATION_OIDC_CLIENT_SECRETClient secret used alongside the client ID to authenticate to the Trustification Bombastic API.
TRUSTIFICATION_SUPPORTED_CYCLONEDX_VERSIONSpecifies the CycloneDX SBOM version that is supported and generated by the system.
Rerun the last pipeline run.
- Alternatively, switch to you application’s source repository in GitLab, make a minor change, and commit it to trigger a new pipeline run.
2.2. Adding secrets to GitLab using CLI Copy linkLink copied to clipboard!
Procedure
Create a project with two files:
- env_vars.sh
- glab-set-vars
Update the
env_vars.shfile with the following environment variables:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the
glab-set-varsfile with the following information:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Load the environment variables into your current shell session:
source env_vars.sh
source env_vars.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow Make the
glab-set-varsscript executable, and run it with your repository name to set the variables in your GitLab repository.chmod +x glab-set-vars ./glab-set-vars your_repository_name
chmod +x glab-set-vars ./glab-set-vars your_repository_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Rerun the last pipeline run.
- Alternatively, switch to your application’s source repository in GitLab, make a minor change, and commit it to trigger a new pipeline run.
Revised on 2024-12-13 16:47:42 UTC