{"id":28496046,"url":"https://github.com/sonarsource/sonar-custom-plugin-example","last_synced_at":"2025-07-02T10:31:01.469Z","repository":{"id":12433369,"uuid":"71792578","full_name":"SonarSource/sonar-custom-plugin-example","owner":"SonarSource","description":"Shows how to write a SonarQube Server plugin","archived":false,"fork":false,"pushed_at":"2025-02-07T14:07:12.000Z","size":1316,"stargazers_count":148,"open_issues_count":0,"forks_count":160,"subscribers_count":37,"default_branch":"10.x","last_synced_at":"2025-06-08T11:51:24.659Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SonarSource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-24T13:36:35.000Z","updated_at":"2025-04-11T01:29:14.000Z","dependencies_parsed_at":"2023-02-15T10:00:44.340Z","dependency_job_id":"94cd5c1c-5525-4dd8-b37e-368a3c870ca2","html_url":"https://github.com/SonarSource/sonar-custom-plugin-example","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SonarSource/sonar-custom-plugin-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-custom-plugin-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-custom-plugin-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-custom-plugin-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-custom-plugin-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SonarSource","download_url":"https://codeload.github.com/SonarSource/sonar-custom-plugin-example/tar.gz/refs/heads/10.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-custom-plugin-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263120595,"owners_count":23416848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T11:38:30.435Z","updated_at":"2025-07-02T10:31:01.453Z","avatar_url":"https://github.com/SonarSource.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"SonarQube Server Custom Plugin Example [![Build Status](https://travis-ci.org/SonarSource/sonar-custom-plugin-example.svg?branch=7.x)](https://travis-ci.org/SonarSource/sonar-custom-plugin-example)\n==========\n\nAn example SonarQube plugin compatible with SonarQube Server 10.x.\n\nSonar's [Clean Code solutions](https://www.sonarsource.com/solutions/clean-code/?utm_medium=referral\u0026utm_source=github\u0026utm_campaign=clean-code\u0026utm_content=sonar-custom-plugin-example) help developers deliver high-quality, efficient code standards that benefit the entire team or organization.\n\nBack-end\n--------\n\nTodo...\n\n### Building\n\nTo build the plugin JAR file, call:\n\n```\nmvn clean package\n```\n\nThe JAR will be deployed to `target/sonar-example-plugin-VERSION.jar`. Copy this to your SonarQube Server's `extensions/plugins/` directory, and restart the server.\n\nFront-end\n---------\n\nThis plugin registers 4 extension pages in the SonarQube Server web app. These pages demonstrate how to extend SonarQube Server's UI with new pages and interfaces.\n\n### Prerequisites\n\n* [NodeJS](https://nodejs.org/en/)\n\n### Scripts\n\n* `npm install` to install your dependencies.\n* `npm start` to start a proxy server on port 3000 to debug your JS code.  \n  *Note: This plugin must first be deployed and installed on your SonarQube Server instance, otherwise the extension paths will not be registered. See above under Back-end \u003e Building*  \n  This will proxy to a running SonarQube Server instance, but allow you to use your own local JavaScript instead of what was bundled with your plugin. Once started, you can access `http://localhost:3000` in your browser, and use SonarQube Server as you normally would.  \n  You can use a different port by using the `PORT` environment variable. Example:  \n  ```\n  PORT=6060 npm start\n  ```\n  You can control to which SonarQube instance you proxy by setting the `PROXY_URL` environment variable to any valid URL (defaults to `http://localhost:9000`). Example:  \n  ```\n  PROXY_URL=https://sonarqube.example.com npm start\n  ```\n* `npm test` to start watching your files for changes, and run tests accordingly.\n* `npm run build` to build your front-end code.  \n  You should not usually need to call this; instead, it should be part of your package-building process.  \n  See Back-end \u003e Building above.\n\n### Building\n\nThis example plugin uses [Webpack](https://webpack.js.org/) for building the final JavaScript. Whatever build system you choose to use, the final result *MUST* adhere to the following rules:\n\n* 1 entry file *per extension page*.\n* The name of each entry file must correspond to the `page_id` of the registered page (see `src/main/java/org/sonarsource/plugins/example/web/MyPluginPageDefinition.java` and compare with the entry points in `conf/webpack/webpack.config.js`).\n* Each entry file must be located in the resulting JAR's `static/` folder.\n\nThe building process should be included in your full packaging process. In this example plugin, `mvn package` will call `npm run build` prior to finalizing the JAR package.\n\n### Testing\n\nThis project uses [Jest](https://jestjs.io/) for testing. Running `npm test` will run Jest in `--watch` mode. You can find the configuration for Jest in `package.json`.\n\n### How to use these files\n\nIt is recommended you check out the sources in `src/main/js/` directly. The code is well-commented and provides real-world examples of how to interact with SonarQube Server.\n\nThe pages are registered in `src/main/java/org/sonarsource/plugins/example/web/MyPluginPageDefinition.java`, and their respective front-end source code is located in `src/main/js/`. These examples use different stacks to demonstrate different possibilities:\n\n* React JS examples (recommended, SonarQube Server uses React 16):\n  * `src/main/js/portfolio_page/`\n  * `src/main/js/admin_page/`\n* Backbone JS example: `src/main/js/project_page/`\n* Vanilla JS example: `src/main/js/global_page/`\n\n#### Helper APIs exposed by SonarQube Server\n\nThere are several helper APIs exposed by SonarQube Server, like functions to make authenticated API requests.\n\nYou can find the full list of exposed helpers [here](https://github.com/SonarSource/sonarqube/blob/master/server/sonar-web/src/main/js/app/components/extensions/exposeLibraries.ts).\n\nThe included pages contain several examples:\n\n* **API calls (`window.SonarRequest`)**  \n  Check `src/main/js/common/api.js` for some examples.\n\n* **Localization (`window.t()` and `window.tp()`)**  \n  Localizable UI strings are defined in `src/main/resources/org/sonar/l10n/example/`. They are loaded at startup time and can used by the global `t()` and `tp()` functions. See `src/main/js/admin_page/components/InstanceStatisticsApp.js` and `src/main/js/portfolio_page/components/VersionsMeasuresHistoryApp.js` for some examples. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonarsource%2Fsonar-custom-plugin-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonarsource%2Fsonar-custom-plugin-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonarsource%2Fsonar-custom-plugin-example/lists"}