sonar_delete_project
Delete a SonarQube project and revoke associated tokens.
Description
Permanently removes a SonarQube project and all its associated data including analysis history, issues, and tokens. This operation cannot be undone.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
projectKey | string | Yes | - | Project key to delete |
confirm | boolean | Yes | - | Must be true to execute |
Usage
Delete Project
Delete the old test project from SonarQube
Tool call:
{
"projectKey": "old-test-project-abc123",
"confirm": true
}
Response Format
Successful Deletion
PROJECT DELETION
━━━━━━━━━━━━━━━━
⚠️ WARNING: This action is PERMANENT and cannot be undone!
📊 PROJECT TO DELETE:
Key: old-test-project-abc123
Name: Old Test Project
Last Analysis: 2023-12-15 10:30:00
Statistics:
├── Issues: 156
├── Analyses: 45
└── History: 3 months
🔑 ASSOCIATED TOKENS:
• old-test-project-token (will be revoked)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ DELETION COMPLETE
✓ Project deleted: old-test-project-abc123
✓ Token revoked: old-test-project-token
✓ Local config removed: bobthefixer.env
The project has been permanently removed from SonarQube.
To create a new project, run sonar_auto_setup.
Deletion Prevented
PROJECT DELETION PREVENTED
━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ Cannot delete project
REASON: confirm parameter must be true
This is a destructive operation that permanently removes:
• All analysis history
• All issues and their status
• All quality gate history
• All associated tokens
To proceed, explicitly set:
{
"projectKey": "old-test-project-abc123",
"confirm": true
}
Project Not Found
PROJECT DELETION FAILED
━━━━━━━━━━━━━━━━━━━━━━━
❌ Project not found
Key: nonexistent-project-xyz
Server: http://localhost:9000
POSSIBLE CAUSES:
1. Project key is incorrect
2. Project was already deleted
3. Token doesn't have access to this project
SUGGESTIONS:
1. Check project key in SonarQube UI
2. Use sonar_config_manager to view current project
3. List available projects in SonarQube dashboard
What Gets Deleted
| Item | Deleted |
|---|---|
| Project | ✅ |
| Analysis history | ✅ |
| Issues | ✅ |
| Quality gate history | ✅ |
| Project-specific tokens | ✅ |
| Local bobthefixer.env | ✅ |
| Source code | ❌ (on your disk) |
| Global tokens | ❌ |
Safety Features
| Feature | Description |
|---|---|
| Explicit key | Must specify project key |
| Confirmation required | Must set confirm: true |
| Shows preview | Displays what will be deleted |
| Reports results | Confirms what was deleted |
Examples
Example 1: Delete Old Project
Prompt:
Delete the old-api-project from SonarQube
Tool Call:
{
"projectKey": "old-api-project-def456",
"confirm": true
}
Example 2: Clean Up Test Project
Prompt:
I'm done with my test project, delete it
Tool Call:
{
"projectKey": "test-project-temp123",
"confirm": true
}
Example 3: Fresh Start
Prompt:
Delete everything and start over with this project
Tool Call:
{
"projectKey": "current-project-abc123",
"confirm": true
}
Then:
// After deletion, create new project
sonar_auto_setup
When to Use
| Scenario | Recommendation |
|---|---|
| Project no longer needed | ✅ Use this tool |
| Want to start fresh | ✅ Delete then sonar_auto_setup |
| Clean up old projects | ⚠️ Consider sonar_cleanup instead |
| Remove test data | ✅ Use this tool |
| Production project | ⚠️ Double-check before deleting |
Best Practices
- Double-check the project key - No recovery after deletion
- Export data first - If you need history
- Use cleanup for bulk - sonar_cleanup for multiple old projects
- Verify project is correct - Run sonar_config_manager first
Common Issues
"Permission denied"
Cause: Token lacks delete permission.
Solution:
- Check token has project admin rights
- Generate new token with proper permissions
- Or delete via SonarQube UI
"Project has dependencies"
Cause: Other projects reference this one.
Solution:
- Remove dependencies first
- Check for portfolio/application inclusions
- Delete via SonarQube UI if needed
"Token still works after delete"
Cause: Global token, not project token.
Solution: Global tokens are not affected by project deletion.
After Deletion
To set up a new project after deletion:
1. Run sonar_auto_setup
Creates new project with fresh configuration
2. Run sonar_scan_project
Analyze code and populate new project
Related Tools
sonar_cleanup- Bulk cleanup old projectssonar_config_manager- View current projectsonar_auto_setup- Create new project