Skip to content

Commit 2d7dd81

Browse files
add github sonarqube guide
1 parent af67ce7 commit 2d7dd81

File tree

4 files changed

+1113
-0
lines changed

4 files changed

+1113
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Automate code quality workflows with GitHub and SonarQube in E2B sandboxes
3+
linkTitle: GitHub and SonarQube quality checks
4+
summary: Build AI-powered code quality workflows using E2B sandboxes with Docker's MCP catalog to automate GitHub and SonarQube integration.
5+
description: Learn how to create E2B sandboxes with MCP servers, analyze code quality with SonarQube, and generate quality-gated pull requests using GitHub—all through natural language interactions with Claude.
6+
tags: [devops]
7+
params:
8+
featured: true
9+
time: 40 minutes
10+
image:
11+
resource_links:
12+
- title: E2B Documentation
13+
url: https://e2b.dev/docs
14+
- title: Docker MCP Catalog
15+
url: https://hub.docker.com/mcp
16+
- title: Sandboxes
17+
url: https://docs.docker.com/ai/mcp-catalog-and-toolkit/sandboxes/
18+
---
19+
20+
This guide demonstrates how to build an AI-powered code quality workflow using
21+
[E2B sandboxes](https://e2b.dev/docs) with Docker’s MCP catalog. You’ll create
22+
a system that automatically analyzes code quality issues in GitHub repositories
23+
using SonarQube, then generate pull requests with fixes.
24+
25+
## What you'll build
26+
27+
You'll build a Node.js script that spins up an E2B sandbox, connects GitHub
28+
and SonarQube MCP servers, and uses Claude to analyze code quality and propose
29+
improvements.
30+
31+
## What you'll learn
32+
33+
In this guide, you'll learn:
34+
35+
- How to create E2B sandboxes with multiple MCP servers
36+
- How to configure GitHub and SonarQube MCP servers for AI workflows
37+
- How to use Claude CLI inside sandboxes to interact with external tools
38+
- How to build automated code review workflows that create quality-gated
39+
pull requests
40+
41+
## Why use E2B sandboxes?
42+
43+
Running this workflow in E2B sandboes provides several advantages over
44+
local execution:
45+
46+
- Security: AI-generated code runs in isolated containers, protecting your
47+
local environment and credentials
48+
- Zero setup: No need to install SonarQube, GitHub CLI, or manage dependencies
49+
locally
50+
- Scalability: Resource-intensive operations like code scanning run in the
51+
cloud without consuming local resources
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: Customize a code quality check workflow
3+
linkTitle: Customize workflow
4+
summary: Adapt your GitHub and SonarQube workflow to focus on specific quality issues, integrate with CI/CD, and set custom thresholds.
5+
description: Learn how to customize prompts for specific quality issues, filter by file patterns, set quality thresholds, and integrate your workflow with GitHub Actions for automated code quality checks.
6+
weight: 20
7+
---
8+
9+
Now that you understand the basics of automating code quality workflows with
10+
GitHub and SonarQube in E2B sandboxes, you can customize the workflow
11+
for your needs.
12+
13+
## Focus on specific quality issues
14+
15+
Modify the prompt to prioritize certain issue types:
16+
17+
```javascript
18+
const prompt = `Using SonarQube and GitHub MCP tools:
19+
20+
Focus only on:
21+
- Security vulnerabilities (CRITICAL priority)
22+
- Bugs (HIGH priority)
23+
- Skip code smells for this iteration
24+
25+
Analyze "${repoPath}" and fix the highest priority issues first.`;
26+
```
27+
28+
## Integrate with CI/CD
29+
30+
Add this workflow to GitHub actions to run automatically on pull requests:
31+
32+
```yaml
33+
name: Automated quality checks
34+
on:
35+
pull_request:
36+
types: [opened, synchronize]
37+
38+
jobs:
39+
quality:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: '18'
46+
- run: npm install
47+
- run: node 06-quality-gated-pr.js
48+
env:
49+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
50+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
53+
GITHUB_OWNER: ${{ github.repository_owner }}
54+
GITHUB_REPO: ${{ github.event.repository.name }}
55+
SONARQUBE_ORG: your-org-key
56+
```
57+
58+
## Filter by file patterns
59+
60+
Target specific parts of your codebase:
61+
62+
```javascript
63+
const prompt = `Analyze code quality but only consider:
64+
- Files in src/**/*.js
65+
- Exclude test files (*.test.js, *.spec.js)
66+
- Exclude build artifacts in dist/
67+
68+
Focus on production code only.`;
69+
```
70+
71+
## Set quality thresholds
72+
73+
Define when PRs should be created:
74+
75+
```javascript
76+
const prompt = `Quality gate thresholds:
77+
- Only create PR if:
78+
* Bug count decreases by at least 1
79+
* No new security vulnerabilities introduced
80+
* Code coverage doesn't decrease
81+
* Technical debt reduces by at least 15 minutes
82+
83+
If changes don't meet these thresholds, explain why and skip PR creation.`;
84+
```
85+
86+
## Next steps
87+
88+
Learn how to troubleshoot common issues.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Troubleshoot code quality workflow issues
3+
linkTitle: Troubleshooting
4+
summary: Resolve common issues with E2B sandboxes, MCP server connections, and GitHub/SonarQube integration.
5+
description: Solutions for MCP tools not loading, authentication errors, permission issues, workflow timeouts, and other common problems when building code quality workflows with E2B.
6+
weight: 30
7+
---
8+
9+
This page covers common issues you might encounter when building code quality
10+
workflows with E2B sandboxes and MCP servers, along with their solutions.
11+
12+
If you're experiencing problems not covered here, check the
13+
[E2B documentation](https://e2b.dev/docs).
14+
15+
## MCP tools not available
16+
17+
Issue: Claude reports `I don't have any MCP tools available`.
18+
19+
Solution:
20+
21+
1. Verify you're using the authorization header:
22+
23+
```plaintext
24+
--header "Authorization: Bearer ${mcpToken}"
25+
```
26+
27+
2. Check you're waiting for MCP initialization:
28+
29+
```javascript
30+
await new Promise(resolve => setTimeout(resolve, 1000));
31+
```
32+
33+
3. Ensure credentials are in both `envs` and `mcp` configuration.
34+
4. Verify your API tokens are valid and have proper scopes.
35+
36+
## GitHub tools work but SonarQube doesn't
37+
38+
Issue: GitHub MCP tools load but SonarQube tools don't appear.
39+
40+
Solution: SonarQube MCP server requires GitHub to be configured simultaneously.
41+
Always include both servers in your sandbox configuration, even if you're only
42+
testing one.
43+
44+
## Claude can’t access private repositories
45+
46+
Issue: “I don’t have access to that repository”.
47+
48+
Solution:
49+
50+
1. Verify your GitHub token has `repo` scope (not just `public_repo`).
51+
2. Test with a public repository first.
52+
3. Ensure the repository owner and name are correct in your `.env`.
53+
54+
## Workflow times out or runs too long
55+
56+
Issue: Workflow doesn’t complete or Claude credits run out.
57+
58+
Solutions:
59+
60+
1. Use `timeoutMs: 0` for complex workflows to allow unlimited time.
61+
2. Break complex workflows into smaller, focused tasks.
62+
3. Monitor your Anthropic API credit usage.
63+
4. Add checkpoints in prompts: “After each step, show progress before continuing”.

0 commit comments

Comments
 (0)