Repository navigation
Conversation
The gerrit output always voted on 'Code-Review' and 'Verified' with -1/+1 whenever a report was found. There was no way to send the reports without voting, and the vote values could not be adjusted to the label ranges configured in Gerrit. The labels to vote on and the vote values used on failure and on success can now be set with the new 'CC_GERRIT_LABELS' environment variable, e.g. 'Verified=-1/1,Code-Review=-1/0'. An empty value sends the reports as comments without any vote. The tag of the review can be set with the 'CC_GERRIT_TAG' environment variable. The environment variables are validated before the conversion, so a typo results in an error message instead of a silently different review. If 'CC_GERRIT_LABELS' is not set then the review keeps its previous behaviour, but a warning is logged to suggest the new configuration. Co-Authored-By: Claude Code <noreply@anthropic.com>
The review voted -1 on the configured labels for any report, so a change which only introduced a 'STYLE' or a 'LOW' severity issue was rejected by the pipeline in the same way as a change which introduced a critical issue. The new 'CC_GERRIT_FAIL_ON_SEVERITY' environment variable sets the lowest severity level which makes the review fail. Reports with a lower severity are still sent as inline comments, they just don't result in a negative vote, so the review remains informative while the vote follows the quality gate. The message of the review also shows whether any report reached the configured severity level, and if no label is voted on it tells the reviewers that no vote was cast. If the variable is not set then any report makes the review fail, which is the previous behaviour. Co-Authored-By: Claude Code <noreply@anthropic.com>
The 'CodeChecker parse -e gerrit' and 'CodeChecker cmd diff -o gerrit' commands document their environment variables in their help output. Extend this list with the new 'CC_GERRIT_LABELS', 'CC_GERRIT_FAIL_ON_SEVERITY' and 'CC_GERRIT_TAG' variables, and update the pasted help output of the diff command in the documentation. Co-Authored-By: Claude Code <noreply@anthropic.com>
The Jenkins integration guide is the documentation of the gerrit output for the users who set up the review job, so explain there how the labels and the severity based quality gate can be configured, and set the new variables in the example build script. Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the gerrit review labels and quality gate configurable
The gerrit output voted
-1on bothCode-ReviewandVerifiedwhenever areport was found, so a change which only introduced a
STYLEor aLOWseverity issue was rejected by the pipeline in the same way as a change which
introduced a critical issue. Reporting an issue and rejecting a change are
two different decisions, and only the first one should always happen.
The labels themselves were hard-coded as well: their names, their vote values
and the tag of the review could not be changed. A review could not be sent
without votes, and a project which does not use one of the two labels — or
does not permit the CI user to vote on it — could not use this output at all,
because Gerrit rejects the whole review, including its comments, if any of
the votes in it is not permitted.
Configuration
Three new environment variables control the review, next to the existing
CC_REPO_DIR,CC_REPORT_URLandCC_CHANGED_FILES:CC_GERRIT_LABELSCode-Review=-1/1,Verified=-1/1CC_GERRIT_FAIL_ON_SEVERITYUNSPECIFIED,STYLE,LOW,MEDIUM,HIGHorCRITICAL.CC_GERRIT_TAGjenkinsExample for a review which reports everything but only rejects a change for a
high severity issue, and which abstains from
Code-Reviewinstead ofapproving the change:
Changes made
inline comment, but only the reports at or above
CC_GERRIT_FAIL_ON_SEVERITYresult in a negative vote. Minor findings aretherefore visible in the review without failing the quality gate.
CodeChecker found 3 issue(s) in the code. 1 of them are at or above the 'HIGH' severity.or... None of them are at or above the 'HIGH' severity., and it tells the reviewers when no vote was cast at all.configurable. A label which is not listed is not sent, so the reports can
be published without any vote.
CodeChecker parse -e gerritandCodeChecker cmd diff -o gerritalreadycall
mandatory_env_var_is_set()before doing any work, so an invalidseverity level or a malformed label results in an error message instead of
a silently different review.
mode, the severity gate (including reports without a severity) and the
validation of the environment variables.
CodeChecker parseand
CodeChecker cmd diff, indocs/web/diff.mdand in the Jenkinsintegration guide, whose example build script sets them.
Compatibility
If none of the new variables is set, the generated review is identical to the
previous one, and so is the message. In this case a warning is logged which
points to the new configuration.
Testing
(
pytest tests/unit/output/gerrit): 18 passed, including the 4pre-existing tests which pin the legacy behaviour of the output.
mypy --ignore-missing-imports codechecker_report_converter,pylintwith the repository
.pylintrcandpycodestyleon the modified Pythonfiles — clean.
(
analyzer/tests/functional/analyze_and_parse,web/tests/functional/diff_local_remote) were not run locally, they needa full CodeChecker build.
Known limitation
The exit code of
CodeChecker cmd diffandCodeChecker parseis2whenthere is any report difference, independently of this quality gate, so a
Jenkins build step still fails for a change with only minor findings. A A
severity aware exit policy is a possible follow-up, this change only affects
what is sent to Gerrit.
Commits
[feat] Make the gerrit review labels and tag configurable[feat] Add severity based quality gate to the gerrit output[doc] Document the gerrit output environment variables in the CLI help[doc] Describe the gerrit labels and quality gate in the Jenkins guide