ci: analyse each branch as itself, not as main !259

merged merged by cmc on 2026-09-05 01:22 UTC · krz/gitbay:sonar-branch into main

1 file changed, +12 −1

Layout: unified · split

.gitbay/ci.yml +12 −1
@@ -53,5 +53,16 @@ jobs:
5353 unzip -q -o "$HOME_DIR/.sonar/sonar-scanner.zip" -d "$HOME_DIR/.sonar/"
5454 rm -f "$HOME_DIR/.sonar/sonar-scanner.zip"
5555 fi
56 # Analyse each branch as itself. Without this every branch is
57 # recorded against the project's main branch, so a feature branch
58 # replaces main's results — a branch that removes findings makes
59 # main look clean before its fix is merged, and one that adds
60 # findings makes main look broken when it is not (#154).
61 BRANCH="${GITBAY_REF:-}"
62 BRANCH="${BRANCH#refs/heads/}"
63 BRANCH_ARG=""
64 if [ -n "$BRANCH" ] && [ "$BRANCH" != "main" ]; then
65 BRANCH_ARG="-Dsonar.branch.name=$BRANCH"
66 fi
5667 SONAR_HOST_URL=https://sonarcloud.io \
57 "$SCANNER/bin/sonar-scanner" -Dsonar.scm.revision="${GITBAY_SHA:-}" || true
68 "$SCANNER/bin/sonar-scanner" -Dsonar.scm.revision="${GITBAY_SHA:-}" $BRANCH_ARG || true