Using It in CI
Running commitfence review in a build pipeline, and what its exit code means there.
On this page
What a pipeline needs#
The command line alone, commitfence-cli-<system>, is what a pipeline runs. A review builds the changed projects, so the machine needs the .NET SDK, and the repository needs the commits the review compares, not a shallow clone with only the last one.
Review a branch#
To judge what a branch adds to its target, review the range of commits:
$ commitfence review --base origin/main
--head names the other end of the range; without it the range ends at the current commit. To judge a whole folder, old breaches included, as of the last commit:
$ commitfence review --all
Fail the step#
The exit code is the verdict: 0 lets the step pass and anything else fails it, so no script is needed around the command. Exit code 2 means the review could not be completed, for instance because a revision is not there: see Exit codes.
$ commitfence review --base HEAD~1src/Shop/Invoice.cs(7,9): error TEAM010: No braces around a single-line ifsrc/Shop/Invoice.cs(5,17): warning CA1822: Member 'IsOverdue' does not access instance data and can be marked as static [Shop, net11.0]src/Shop/Invoice.cs(7,28): error TEAM012: Use IClock, not DateTime.NowShop (net11.0): reviewedHEAD~1..HEAD: 3 changed files. Rule files changed: .editorconfig, commitfence.json. 2 changed files of no known language were not looked at. 1 of 1 files reviewed, 1 of 1 builds checked: 2 blocking, 1 warning.exit code 1
The commands above are real runs on a developer machine. A step that downloads the command line for your runner's system depends on the runner; take the file from the downloads.
Something wrong or unclear on this page? Tell us on GitHub