reference Environment variables

OPENGREP_BASELINE_COMMIT

Also spelled
SEMGREP_BASELINE_COMMIT
Value
a git revision
Equivalent to
--baseline-commit
See also
OPENGREP_BASELINE_REF

The baseline of opengrep scan and opengrep ci, used when --baseline-commit is not given. Only the findings that are new relative to the baseline are reported. The value is any revision that git accepts.

Four variables can set the baseline. The first one that is set takes precedence, in this order: OPENGREP_BASELINE_COMMIT, SEMGREP_BASELINE_COMMIT, OPENGREP_BASELINE_REF and SEMGREP_BASELINE_REF. A variable set to the empty string is treated as unset.

Examples

A baseline from the environment

rule.yaml
rules:  - id: no-print    pattern: print(...)    message: use logging instead of print    languages: [python]    severity: INFO
a.py
print("old")
Command and result
$ git init -q && git add . && git commit -qm one
$ echo 'print("new")' > b.py && git add b.py && git commit -qm two
$ OPENGREP_BASELINE_COMMIT=HEAD~1 opengrep scan -q --config rule.yaml --files-with-matches .
b.py
$ OPENGREP_BASELINE_COMMIT=HEAD~1 opengrep scan --config rule.yaml --baseline-commit HEAD~1 . 2>&1 >/dev/null | grep ignoring
[00.04][WARNING]: --baseline-commit is given; ignoring $OPENGREP_BASELINE_COMMIT