Note: The following are never sent to SecureFlag: source code, diffs, file contents, file names or paths, and commit messages.Variable | Description | Required |
SECUREFLAG_API_KEY | SecureFlag API token with the "Write SDLC data" scope. Store it as a CI secret. | Yes |
SECUREFLAG_COMMANDS | Set to collect-metrics. | Yes |
SECUREFLAG_REPOSITORY | Repository identifier reported to SecureFlag (e.g. my-org/my-repo). Keep it stable across runs: it identifies the repository on the platform. | No — auto-detected from the CI environment, falling back to the git origin remote |
name: SecureFlag Commit Metrics
on: push: tags: - '*' # Run on schedule (configure as needed) # schedule: # - cron: '0 2 * * *'
jobs: secureflag_commit_metrics: name: SecureFlag Commit Metrics runs-on: ubuntu-latest container: image: registry.gitlab.com/secureflag-community/sf-runner:latest
env: SECUREFLAG_API_KEY: ${{ secrets.SECUREFLAG_API_KEY }} SECUREFLAG_COMMANDS: collect-metrics # Tag pipelines run on the tag ref ($GITHUB_REF_NAME would be the tag name): # pin the branch identifier reported to SecureFlag SECUREFLAG_BRANCH: main
continue-on-error: true
steps: - name: Checkout repository uses: actions/checkout@v4 with: # Full history is required fetch-depth: 0
- name: Run SecureFlag CI Runner run: /app/entrypoint.sh
stages:
- tests
secureflag_commit_metrics: stage: tests image: registry.gitlab.com/secureflag-community/sf-runner:latest
variables: SECUREFLAG_COMMANDS: collect-metrics # Full history is required GIT_DEPTH: 0 # Tag pipelines run on the tag ref ($CI_COMMIT_REF_NAME would be the tag # name): pin the branch identifier reported to SecureFlag SECUREFLAG_BRANCH: main
script: - /app/entrypoint.sh
rules: # Run on tags - if: $CI_COMMIT_TAG # Run on schedules - if: '$CI_PIPELINE_SOURCE == "schedule"'
allow_failure: true
image: registry.gitlab.com/secureflag-community/sf-runner:latest
# Full history is requiredclone: depth: full
definitions: steps: - step: &secureflag_commit_metrics name: SecureFlag Commit Metrics script: - export SECUREFLAG_COMMANDS=collect-metrics # Tag pipelines run on the tag ref ($BITBUCKET_BRANCH is unset there): # pin the branch identifier reported to SecureFlag - export SECUREFLAG_BRANCH=main - /app/entrypoint.sh || true
pipelines: # Run on tags tags: '*': - step: *secureflag_commit_metrics
# Run on a schedule (configure in Bitbucket: # Repository settings -> Pipelines -> Schedules) custom: secureflag-commit-metrics: - step: *secureflag_commit_metrics