Bifrost

Proof of concept plugin that lists Gitea repositories and creates SonarQube Community Build projects for selected repositories.

Target and status

  • SonarQube Community Build: 25.9.0.112764 (tested by loading the plugin in the exact Community Build image).
  • Sonar plugin API: 13.0.0.3026.
  • Java: 17.
  • Artifact: sonar-bifrost-plugin-<version>.jar.
  • Generated build version: @PLUGIN_VERSION@.
  • Maven is used because SonarSource publishes the supported plugin packaging extension for Maven.

The Docker build completed with Java 17, all eight unit tests passed, and the exported JAR manifest contains the expected plugin key, class, version, name, and minimum plugin API version. The exact 25.9.0.112764 Community Build started with the plugin, reported UP, and served the page bundle with HTTP 200. Live Gitea calls and authenticated browser import behavior have not been verified here.

Tree

.
├── .claude/skills/                  # Eleven project skills
├── .gitea/workflows/build.yml       # Gitea Actions CI and release pipeline
├── .mvn/wrapper/                   # Maven distribution pin
├── scripts/                         # Version, changelog, and release helpers
├── src/main/java/cc/tordais/sonar/bifrost/
│   ├── BifrostPlugin.java
│   ├── config/BifrostProperties.java
│   ├── gitea/GiteaClient.java
│   ├── gitea/GiteaRepository.java
│   ├── page/ImportPage.java
│   ├── service/OrganizationPolicy.java
│   ├── service/ProjectKey.java
│   └── ws/BifrostWebService.java
├── src/main/resources/static/import.js
├── src/test/java/cc/tordais/sonar/bifrost/
│   ├── gitea/GiteaClientTest.java
│   └── service/{OrganizationPolicyTest,ProjectKeyTest}.java
├── CHANGELOG.md
├── Dockerfile
├── docker-compose.yml
├── Makefile
├── mvnw, mvnw.cmd
└── pom.xml

Local build

The launcher bootstraps the pinned Maven 3.9.9 distribution and verifies its SHA-512 checksum. It requires network access to Maven Central on first use.

make build

On Windows, run mvnw.cmd -B -Drevision=1.2.3 verify. To force a version manually, pass -Drevision=1.2.3 to Maven.

Docker build

Docker builds the plugin using a pinned Maven/JDK image and exports the JAR without a local JDK or Maven installation:

docker build --build-arg REVISION="$(sh scripts/version.sh)" --target export --output type=local,dest=dist .

Pass a version with --build-arg REVISION=1.2.3. The Docker context excludes Git metadata, so pass the output of scripts/version.sh from the host to preserve tag-based versions. A direct Docker build without REVISION uses the no-Git fallback.

Install and configure

  1. Copy the JAR to <sonarqubeHome>/extensions/plugins/ and restart SonarQube. In Docker, mount it at /opt/sonarqube/extensions/plugins/.
  2. In Administration > Configuration, set Gitea URL and token, selection mode, allowed organizations, and the personal repositories option.
  3. Grant the user the global Create Projects permission.
  4. Open Import from Gitea, select organizations or All, select repositories, then choose Import.

The token is held only by the plugin server. Project creation and repository-link creation use same-origin SonarQube REST requests from the logged-in browser session. The plugin API checks the caller's Create Projects permission and revalidates each selected organization before returning approval.

Test scenario

Use the Compose stack for a disposable SonarQube and Gitea setup:

make build
export BIFROST_PLUGIN_JAR="target/sonar-bifrost-plugin-$(sh scripts/version.sh).jar"
docker compose up -d

Complete Gitea's first-run account setup at http://localhost:3000. Create organizations alpha-lab and beta-lab, then create two repositories in each: api and web. This deliberately repeats repository names across organizations. Create a token that can read all four repositories and set it in SonarQube's global plugin settings. On SonarQube, grant the test account Create Projects and import the four repositories. Expected keys are alpha-lab_api, alpha-lab_web, beta-lab_api, and beta-lab_web; no collision should occur. Try a second pair of names that sanitize to the same key to verify collision feedback.

The Compose Gitea URL from the SonarQube container is http://gitea:3000. The initial settings are blank and must be configured in the UI.

Versioning

Git tags vMAJOR.MINOR.PATCH are the release source of truth. Commit subjects follow Conventional Commits. feat: requests a minor release, fix:, perf:, and refactor: request a patch, and ! or a BREAKING CHANGE: footer requests a major release. Other types do not request a release.

Examples:

  • At tag v1.2.3: scripts/version.sh returns 1.2.3.
  • After two commits since v1.2.3, without a release-triggering change: it returns 1.2.3-SNAPSHOT.2+<short-sha>.
  • With no tags: it returns 0.1.0-SNAPSHOT.<commit-count>+<short-sha>.
  • To force a local version: sh ./mvnw -Drevision=2.0.0-SNAPSHOT package.

If the workflow pushes a tag but release publication fails, inspect the tag and changelog commit first. Re-run the release API request for the existing tag after confirming there is no existing release. Do not force-move a published tag. If the tag itself points to the wrong commit, coordinate a deliberate corrective tag/release; do not silently rewrite it.

Changelog

CHANGELOG.md follows Keep a Changelog 1.1.0. The intended mapping is feat: to Added; fix: to Fixed; perf: and refactor: to Changed; deprecate: to Deprecated; revert: to Removed; security: to Security. Breaking changes are prefixed with BREAKING:. docs:, chore:, ci:, test:, and style: are excluded.

Edit the [Unreleased] entries by hand before release when generated wording needs correction. sh scripts/changelog.sh X.Y.Z transfers curated entries or generates entries from Conventional Commits, then updates comparison links using GITEA_REPOSITORY_URL. sh scripts/check-changelog.sh validates headings, categories, dates, order, and comparison links.

CI and releases

The Gitea Actions workflow checks out full history/tags, installs Java 17, calculates a version, validates changelog formatting on pull requests, runs Maven verification, and uploads the JAR. On a main-branch push, a release commit/tag and Gitea release are created when Conventional Commits request a bump.

Configure repository variable GITEA_API_URL (for example, https://gitea.example/api/v1), repository variable GITEA_REPOSITORY_URL (the repository web URL), and secret RELEASE_TOKEN. The token needs repository write access to push the changelog commit/tag and create a release with an asset. For protected branches, allow this token identity to push the release commit to main, or use a dedicated release branch and adjust GITEA_MAIN_BRANCH. Actions use GitHub-hosted action sources (actions/checkout, actions/setup-java, actions/upload-artifact); an isolated act_runner may need those repositories mirrored or outbound GitHub access.

Skills

The .claude/skills/<name>/SKILL.md files are project instructions:

  • sonarqube-plugin-development: entry point, extension lifecycle, manifest, and public API constraints.
  • sonarqube-frontend-extension: page API, UI, bundle, and accessibility.
  • java-best-practices: Java 17 boundaries, immutability, resource handling, and errors.
  • java-testing: deterministic unit tests and HTTP mocking.
  • gitea-api-client: Gitea paths, tokens, pagination, timeouts, and status mapping.
  • secure-coding-plugin: URL/input validation, permissions, secrets, CSRF, and dependencies.
  • maven-build-packaging: pinned Maven build and plugin JAR packaging.
  • release-versioning-changelog: tag bumps, changelog structure, and release flow.
  • gitea-actions-ci: act_runner constraints and release workflow.
  • docker-test-environment: pinned SonarQube, PostgreSQL, Gitea, and plugin mount.
  • project-workflow: language, evidence, implementation order, and definition of done.

When the SonarQube target changes, update version-sensitive skill claims only after checking official SonarSource docs and target source/artifact metadata. Then update API/compiler/manifest pins, rebuild and inspect the JAR, and rerun each checklist. Skills are guidance, not a substitute for version-specific verification.

Troubleshooting

  • Plugin rejected at startup: verify the JAR manifest Plugin-Key, Plugin-Version, and Sonar-Version against the target API, then inspect web.log.
  • No organizations appear: check the Gitea URL from the SonarQube container, token permissions, organization allowlist, and Gitea logs.
  • 401 or 403 from Gitea: replace the token or grant read access to the relevant organization repositories.
  • Import denied: grant the current SonarQube user Create Projects.
  • Project exists: choose a different source repository or remove the existing project; the plugin does not overwrite projects.
  • Sanitized key collision: rename one repository or organization so their sanitized combined keys differ.
  • SonarQube does not start in Docker: check available memory and the host's vm.max_map_count requirement for the bundled search engine.

Limitations and risks

  • The official plugin API compatibility table omits Community Build 25.9. 13.0.0.3026 was inferred from target server dependency metadata and adjacent releases; the plugin has now built and loaded successfully on the exact 25.9.0.112764 image.
  • The manifest Sonar-Version denotes the minimum plugin API version. The separate sonar.minimumVersion property records the target product release because the documented manifest field does not encode a SonarQube product version.
  • The UTF-8 plugin display name is set to ASCII Bifrost because manifest encoding has not yet been confirmed by inspecting a built JAR.
  • The page uses same-origin REST endpoints api/projects/create and api/project_links/create. Their authenticated parameter and permission behavior still needs a browser import test.
  • Existing-project detection uses api/components/show through the public LocalConnector for each repository. Projects the user cannot browse may return a permission error; the importer stops that organization list rather than guessing that those projects are missing.
  • Create Projects permission is checked against api/users/current through LocalConnector. The unauthenticated route correctly returns HTTP 401, but permission parsing and caller context still need an authenticated check.
  • The global page menu is not conditionally hidden by Create Projects permission because the public page API documents only administrator gating. Every data and import web service checks Create Projects; direct same-origin project creation is also enforced by SonarQube. Menu hiding is a UI limitation.
  • The Gitea token scope and response fields may vary by Gitea version. The local Compose default is Gitea 1.23.8; no external instance was supplied.
  • The Maven launcher is a small pinned-distribution bootstrap, not the upstream Maven Wrapper JAR implementation. It requires network access for initial Maven download; the Docker build used Maven directly.
  • Release scripts and workflow are scaffolding and have not been exercised against a real Gitea runner or protected branch.
S
Description
Plugin for SonarQube for importing projet from Gitea
Readme MIT
145 KiB
0 Stars 1 Watchers 0 Forks
Languages
Java 40.2%
JavaScript 29.7%
Shell 22.8%
PowerShell 5.3%
Dockerfile 1.2%
Other 0.8%