Harness CI
Prelude
GitGuardian CI/CD integration with Harness CI is performed through our CLI application: ggshield.
ggshield is a wrapper around the GitGuardian API for secrets detection, an API key is required for authentication.
Installation
Service accounts are recommended to run this integration.
Please note that service accounts are only available for workspaces under our Growth or Enterprise plan, and their administration is restricted to Managers. If your workspace is under the Free plan, you can still use a personal access token to run this integration.
- Create a service account from the API section of your GitGuardian workspace (or a personal access token if you are on the Free plan).
- Store this API key as a Harness text secret: in Project Settings, open Secrets, select New Secret, then Text, and use
gitguardian_api_keyas the identifier. - Add a Run step that runs ggshield to a CI stage that clones your codebase:
- step:
type: Run
name: ggshield
identifier: ggshield
spec:
image: gitguardian/ggshield:latest
shell: Sh
envVariables:
GITGUARDIAN_API_KEY: <+secrets.getValue("gitguardian_api_key")>
command: ggshield secret scan ci
ggshield secret scan ci detects Harness CI and scans the commits of the build: the commits of the pull request in a pull request build, and the pushed commits in a push build.
Triggers
Run the pipeline on pull requests as well as on pushes. On the first push of a new branch, ggshield scans only the last commit of the branch. The pull request build then scans all the commits of the branch.
Self-hosted GitGuardian
With a self-hosted GitGuardian instance, add the GITGUARDIAN_INSTANCE environment variable with the URL of your dashboard. See on-premise configuration.
envVariables:
GITGUARDIAN_API_KEY: <+secrets.getValue("gitguardian_api_key")>
GITGUARDIAN_INSTANCE: https://dashboard.gitguardian.mycorp.local
Kubernetes and other self-managed build infrastructure
On Harness Cloud, the Run step pulls gitguardian/ggshield without further settings. On a Kubernetes cluster build infrastructure, Harness requires a container registry connector: add connectorRef to the step's spec, with a Docker registry connector that can pull gitguardian/ggshield. See Use CI Run steps.
ggshield versions before 1.57.0
Harness CI does not set the CI environment variable by default. ggshield detects Harness CI from version 1.57.0. With an earlier version, ggshield secret scan ci stops with "secret scan ci should only be used in a CI environment". Add CI: "true" to envVariables to run it.