Skip to main content

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

ParameterTypeRequiredDefaultDescription
projectKeystringYes-Project key to delete
confirmbooleanYes-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

ItemDeleted
Project
Analysis history
Issues
Quality gate history
Project-specific tokens
Local bobthefixer.env
Source code❌ (on your disk)
Global tokens

Safety Features

FeatureDescription
Explicit keyMust specify project key
Confirmation requiredMust set confirm: true
Shows previewDisplays what will be deleted
Reports resultsConfirms 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

ScenarioRecommendation
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

  1. Double-check the project key - No recovery after deletion
  2. Export data first - If you need history
  3. Use cleanup for bulk - sonar_cleanup for multiple old projects
  4. Verify project is correct - Run sonar_config_manager first

Common Issues

"Permission denied"

Cause: Token lacks delete permission.

Solution:

  1. Check token has project admin rights
  2. Generate new token with proper permissions
  3. Or delete via SonarQube UI

"Project has dependencies"

Cause: Other projects reference this one.

Solution:

  1. Remove dependencies first
  2. Check for portfolio/application inclusions
  3. 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