Package Information
Documentation
@robertasoliman/n8n-nodes-sonarqube
This is an n8n community node that lets you interact with SonarQube and SonarCloud in your n8n workflows.
SonarQube and SonarCloud are platforms for continuous inspection of code quality. They perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities.
n8n is a fair-code licensed workflow automation platform.
Table of Contents
- Installation
- Credentials
- Supported Resources
- Usage Examples
- API Endpoints Used
- Development
- Requirements
- Compatibility
- Resources
Installation
Follow the installation guide in the n8n community nodes documentation.
Community Node Installation
- Go to Settings > Community Nodes in your n8n instance
- Select Install
- Enter
@robertasoliman/n8n-nodes-sonarqubein the Enter npm package name field - Agree to the risks of using community nodes
- Select Install
Manual Installation
To install the node manually:
npm install @robertasoliman/n8n-nodes-sonarqube
For Docker installations, refer to the npm package installation guide.
Credentials
SonarQube API Credentials
You need to create credentials in n8n to authenticate with SonarQube or SonarCloud:
Environment: Choose between:
- SonarQube (Self-Hosted): Your own SonarQube server
- SonarCloud (SaaS): Cloud-hosted service
Server URL:
- For SonarQube self-hosted: Your server URL (e.g.,
http://localhost:9000orhttps://sonarqube.yourcompany.com) - For SonarCloud: Default is
https://sonarcloud.io
- For SonarQube self-hosted: Your server URL (e.g.,
Token: Personal Access Token for authentication
- SonarQube: Go to User > My Account > Security > Generate Token
- SonarCloud: Go to Account > Security > Generate Token
The token should look like: squ_1234567890abcdef (SonarQube) or similar format.
Generating Tokens
SonarQube (Self-Hosted)
- Log in to your SonarQube instance
- Click on your avatar in the top-right corner
- Go to My Account
- Select the Security tab
- Enter a token name under Generate Tokens
- Click Generate
- Copy the token immediately (it won't be shown again)
SonarCloud
- Log in to SonarCloud
- Click on your avatar in the top-right corner
- Go to My Account
- Select the Security tab
- Enter a token name under Generate Tokens
- Click Generate
- Copy the token immediately (it won't be shown again)
Supported Resources
This node supports the following resources and operations:
Project
- Get Many: Retrieve a list of projects
- Search: Search for projects with filters
Measure
- Get Component: Get measures (metrics) for a specific component/project
- Search History: Search historical measure data for a component
Issue
- Get Many: Retrieve a list of issues
- Search: Search for issues with various filters including:
- Types: Bugs, Vulnerabilities, Code Smells, Security Hotspots
- Severities: Blocker, Critical, Major, Minor, Info
- Statuses: Open, Confirmed, Reopened, Resolved, Closed
- Component keys (project keys)
- Branch and Pull Request filtering
Quality Gate
- Get Many: List all available quality gates
- Get Project Status: Get the quality gate status for a specific project
Usage Examples
Example 1: Get All Projects
- Add the SonarQube node to your workflow
- Select Project as the resource
- Select Get Many as the operation
- Configure Return All to
trueto fetch all projects - Execute the node
Example 2: Get Code Metrics for a Project
- Add the SonarQube node
- Select Measure as the resource
- Select Get Component as the operation
- Enter your project key (e.g.,
my-project-key) - Select metrics like:
ncloc(Lines of Code)bugs(Number of Bugs)vulnerabilities(Number of Vulnerabilities)code_smells(Number of Code Smells)coverage(Test Coverage)duplicated_lines_density(Code Duplication)
- Execute the node
Example 3: Search for Critical Bugs
- Add the SonarQube node
- Select Issue as the resource
- Select Search as the operation
- In Filters:
- Set Component Keys to your project key
- Set Types to
Bug - Set Severities to
CriticalandBlocker - Set Statuses to
Open
- Execute the node
Example 4: Check Quality Gate Status
- Add the SonarQube node
- Select Quality Gate as the resource
- Select Get Project Status as the operation
- Enter your Project Key
- (Optional) Add Branch name in Additional Fields
- Execute the node
Example Workflow: Monitor Code Quality
Create a workflow that:
- Schedule Trigger - Runs daily
- SonarQube: Get Projects - Gets all projects
- Split In Batches - Processes projects one by one
- SonarQube: Get Component Measures - Gets metrics for each project
- SonarQube: Get Project Quality Gate Status - Checks quality gate
- IF - Checks if quality gate failed
- Send Email/Slack - Notifies team if quality gate failed
API Endpoints Used
This node uses the following SonarQube/SonarCloud Web API endpoints:
Authentication
GET /api/authentication/validate- Validate credentials
Projects
GET /api/projects/search- Search and retrieve projects
Measures/Metrics
GET /api/measures/component- Get measures for a componentGET /api/measures/search_history- Search historical measure dataGET /api/metrics/search- List available metrics (used in dropdown)
Issues
GET /api/issues/search- Search for issues (bugs, vulnerabilities, code smells)
Quality Gates
GET /api/qualitygates/list- List all quality gatesGET /api/qualitygates/project_status- Get quality gate status for a project
For complete API documentation, refer to:
Development
Prerequisites
- Node.js >= 18.10
- npm >= 8.0.0
- n8n installed globally or locally
Running Locally
To test the node locally during development:
- Clone the repository:
git clone https://github.com/robertasolimandonofreo/n8n-nodes-sonarqube.git
cd n8n-nodes-sonarqube
- Install dependencies:
npm install
- Build the node:
npm run build
- Link the node to your global n8n installation:
npm link
- In your n8n installation directory, link the package:
cd ~/.n8n/nodes # or your n8n custom nodes directory
npm link @robertasoliman/n8n-nodes-sonarqube
- Start n8n:
n8n start
The SonarQube node should now appear in your n8n instance.
Alternative: Using n8n Development Mode
You can also use n8n's development mode with hot reloading:
- Install dependencies:
npm install
- Start the build in watch mode:
npm run dev
- In another terminal, start n8n with custom nodes:
n8n start --tunnel
Testing
To run tests (once test suite is implemented):
npm test
Linting
To check code quality and style:
npm run lint
To automatically fix linting issues:
npm run lintfix
Building
To build the project for production:
npm run build
This will:
- Compile TypeScript files to JavaScript
- Copy icon files to the
distdirectory - Generate declaration files
The compiled files will be in the dist/ directory.
Publishing
To publish the package to npm:
- Ensure you're logged in to npm:
npm login
- Update the version in
package.json:
npm version patch # or minor, or major
- Build the package:
npm run build
- Run linting:
npm run lint
- Publish to npm:
npm publish
Note: The prepublishOnly script will automatically run build and lint checks before publishing.
Requirements
SonarQube (Self-Hosted)
- Minimum Version: SonarQube 7.9 LTS or later (recommended: latest LTS)
- Authentication: Personal Access Token with appropriate permissions
- Permissions Required:
- Browse on projects
- Execute analysis (if triggering scans)
SonarCloud
- Authentication: Personal Access Token
- Organization Access: Token must have access to the organization
- Permissions Required:
- Browse on projects
- Execute analysis (if triggering scans)
Network Requirements
- The n8n instance must have network access to your SonarQube server or SonarCloud
- For self-hosted SonarQube: Ensure firewall rules allow traffic on the SonarQube port (default: 9000)
- HTTPS is recommended for production environments
Compatibility
- n8n Version: 0.200.0 or later
- Node.js: 18.10 or later
- npm: 8.0.0 or later
Tested with:
- SonarQube Community Edition 10.x
- SonarQube Developer Edition 10.x
- SonarCloud
Resources
- n8n community nodes documentation
- SonarQube Web API Documentation
- SonarCloud Web API Documentation
- SonarQube Official Documentation
- SonarCloud Official Documentation
License
Support
For issues, questions, or contributions, please visit the GitHub repository.
Version History
0.1.0 (Initial Release)
- Initial release with support for:
- Project operations (search, get)
- Measure operations (get component measures, search history)
- Issue operations (search with filters)
- Quality Gate operations (list, get project status)
- Support for both SonarQube and SonarCloud
- Pagination support for list operations
- Dynamic metric loading