Migrate all repos into monorepo context folders
Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Schritt 1: SonarQube URL aus GitLab Deployment-Repo finden
|
||||
Schritt 2: SonarQube Metriken exportieren (braucht SonarQube Token)
|
||||
#>
|
||||
|
||||
$GitLabUrl = "https://git.tech.rz.db.de"
|
||||
$GitLabApiBase = "$GitLabUrl/api/v4"
|
||||
$OutputDir = "project-audit\data\sonarqube"
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
Write-Host "============================================================"
|
||||
Write-Host " SonarQube Daten fuer pathOS"
|
||||
Write-Host "============================================================"
|
||||
|
||||
# === Schritt 1: URL aus GitLab finden ===
|
||||
Write-Host ""
|
||||
Write-Host ">> Schritt 1: SonarQube URL aus GitLab suchen..." -ForegroundColor Yellow
|
||||
|
||||
$GitLabToken = Read-Host "GitLab Token (read_api)"
|
||||
$GitLabHeaders = @{ "PRIVATE-TOKEN" = $GitLabToken }
|
||||
|
||||
# deployment-sonarqube Repo durchsuchen
|
||||
$RepoPath = [Uri]::EscapeDataString("bestellsystem1/infra/deployment-sonarqube")
|
||||
$SonarUrl = $null
|
||||
|
||||
foreach ($File in @("values.yaml", "helmfile.yaml", "Chart.yaml", "values-sonarqube.yaml")) {
|
||||
foreach ($Branch in @("main", "master")) {
|
||||
$Uri = "$GitLabApiBase/projects/$RepoPath/repository/files/$([Uri]::EscapeDataString($File))/raw?ref=$Branch"
|
||||
try {
|
||||
$Resp = Invoke-WebRequest -Uri $Uri -Headers $GitLabHeaders -UseBasicParsing -ErrorAction Stop
|
||||
$Content = $Resp.Content
|
||||
Write-Host " Gefunden: $File ($Branch)" -ForegroundColor Green
|
||||
|
||||
# URL suchen
|
||||
if ($Content -match "(https?://sonar[^\s""']+)") {
|
||||
$SonarUrl = $Matches[1]
|
||||
Write-Host " SonarQube URL: $SonarUrl" -ForegroundColor Green
|
||||
}
|
||||
if ($Content -match "host:\s*(.+)") {
|
||||
Write-Host " Host: $($Matches[1].Trim())"
|
||||
}
|
||||
if ($Content -match "ingress.*host.*:\s*(.+)") {
|
||||
Write-Host " Ingress Host: $($Matches[1].Trim())"
|
||||
}
|
||||
|
||||
# Datei speichern
|
||||
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
|
||||
$Content | Out-File "$OutputDir\deployment-$File" -Encoding UTF8
|
||||
} catch { continue }
|
||||
}
|
||||
}
|
||||
|
||||
# Auch in der Repo-Beschreibung suchen
|
||||
try {
|
||||
$RepoInfo = Invoke-WebRequest -Uri "$GitLabApiBase/projects/$RepoPath" -Headers $GitLabHeaders -UseBasicParsing -ErrorAction Stop
|
||||
$RepoData = $RepoInfo.Content | ConvertFrom-Json
|
||||
Write-Host " Repo-Beschreibung: $($RepoData.description)"
|
||||
} catch {}
|
||||
|
||||
# Bekannte CNP-URL-Muster probieren
|
||||
Write-Host ""
|
||||
Write-Host ">> Probiere bekannte URL-Muster..." -ForegroundColor Yellow
|
||||
$Candidates = @(
|
||||
"https://sonarqube.build.bsz-dev.cnp-test.comp.db.de"
|
||||
"https://sonarqube.bsz-dev.cnp-test.comp.db.de"
|
||||
"https://sonarqube.bsz-infra.cnp-test.comp.db.de"
|
||||
)
|
||||
foreach ($Url in $Candidates) {
|
||||
Write-Host " Teste $Url..." -NoNewline
|
||||
try {
|
||||
$R = Invoke-WebRequest -Uri "$Url/api/system/status" -UseBasicParsing -TimeoutSec 5 -ErrorAction Stop
|
||||
Write-Host " ERREICHBAR!" -ForegroundColor Green
|
||||
$SonarUrl = $Url
|
||||
break
|
||||
} catch {
|
||||
Write-Host " nicht erreichbar" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $SonarUrl) {
|
||||
Write-Host ""
|
||||
Write-Host "SonarQube URL nicht automatisch gefunden." -ForegroundColor Yellow
|
||||
Write-Host "Bitte manuell eingeben (oder Enter zum Ueberspringen):"
|
||||
$SonarUrl = Read-Host "SonarQube URL"
|
||||
if (-not $SonarUrl) {
|
||||
Write-Host "Uebersprungen. Bitte URL beim Team erfragen." -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
# === Schritt 2: SonarQube Metriken ziehen ===
|
||||
Write-Host ""
|
||||
Write-Host ">> Schritt 2: SonarQube Metriken exportieren..." -ForegroundColor Yellow
|
||||
Write-Host " URL: $SonarUrl"
|
||||
Write-Host ""
|
||||
Write-Host " Du brauchst einen SonarQube Token."
|
||||
Write-Host " Erstellen unter: $SonarUrl/account/security"
|
||||
Write-Host " (Login mit GitLab SSO, dann My Account > Security > Generate Token)"
|
||||
Write-Host ""
|
||||
|
||||
$SonarToken = Read-Host "SonarQube Token (oder Enter zum Ueberspringen)"
|
||||
if (-not $SonarToken) {
|
||||
Write-Host "Uebersprungen." -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
|
||||
$SonarAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${SonarToken}:"))
|
||||
$SonarHeaders = @{ "Authorization" = "Basic $SonarAuth" }
|
||||
|
||||
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
|
||||
|
||||
# Projekte auflisten
|
||||
Write-Host " Lade Projekte..." -NoNewline
|
||||
$Projects = @()
|
||||
$Page = 1
|
||||
do {
|
||||
try {
|
||||
$R = Invoke-WebRequest -Uri "$SonarUrl/api/projects/search?ps=100&p=$Page" -Headers $SonarHeaders -UseBasicParsing -ErrorAction Stop
|
||||
$Data = $R.Content | ConvertFrom-Json
|
||||
$Projects += $Data.components
|
||||
$Page++
|
||||
} catch {
|
||||
Write-Host " FEHLER: $($_.Exception.Message)" -ForegroundColor Red
|
||||
break
|
||||
}
|
||||
} while ($Projects.Count -lt $Data.paging.total)
|
||||
Write-Host " $($Projects.Count) Projekte" -ForegroundColor Green
|
||||
|
||||
# Metriken pro Projekt
|
||||
Write-Host " Lade Metriken..."
|
||||
$Metrics = "ncloc,bugs,vulnerabilities,code_smells,coverage,duplicated_lines_density,sqale_rating,reliability_rating,security_rating,alert_status"
|
||||
$Results = @()
|
||||
|
||||
foreach ($P in $Projects) {
|
||||
Write-Host " $($P.key)..." -NoNewline
|
||||
try {
|
||||
$R = Invoke-WebRequest -Uri "$SonarUrl/api/measures/component?component=$($P.key)&metricKeys=$Metrics" -Headers $SonarHeaders -UseBasicParsing -ErrorAction Stop
|
||||
$MData = ($R.Content | ConvertFrom-Json).component.measures
|
||||
$Row = [PSCustomObject]@{
|
||||
Project = $P.key
|
||||
Name = $P.name
|
||||
Lines = ($MData | Where-Object { $_.metric -eq "ncloc" }).value
|
||||
Bugs = ($MData | Where-Object { $_.metric -eq "bugs" }).value
|
||||
Vulnerabilities = ($MData | Where-Object { $_.metric -eq "vulnerabilities" }).value
|
||||
CodeSmells = ($MData | Where-Object { $_.metric -eq "code_smells" }).value
|
||||
Coverage = ($MData | Where-Object { $_.metric -eq "coverage" }).value
|
||||
Duplications = ($MData | Where-Object { $_.metric -eq "duplicated_lines_density" }).value
|
||||
Maintainability = ($MData | Where-Object { $_.metric -eq "sqale_rating" }).value
|
||||
Reliability = ($MData | Where-Object { $_.metric -eq "reliability_rating" }).value
|
||||
Security = ($MData | Where-Object { $_.metric -eq "security_rating" }).value
|
||||
QualityGate = ($MData | Where-Object { $_.metric -eq "alert_status" }).value
|
||||
}
|
||||
$Results += $Row
|
||||
Write-Host " OK" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " Fehler" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# Speichern
|
||||
$Results | Export-Csv "$OutputDir\sonarqube-metrics.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation
|
||||
$Results | ConvertTo-Json -Depth 5 | Out-File "$OutputDir\sonarqube-metrics.json" -Encoding UTF8
|
||||
|
||||
# Markdown
|
||||
$Md = @("# SonarQube Metriken pathOS", "", "| Projekt | Lines | Bugs | Vulns | Smells | Coverage | Dupl% | QGate |")
|
||||
$Md += "|---------|-------|------|-------|--------|----------|-------|-------|"
|
||||
foreach ($R in ($Results | Sort-Object { [int]$_.Lines } -Descending)) {
|
||||
$Md += "| $($R.Name) | $($R.Lines) | $($R.Bugs) | $($R.Vulnerabilities) | $($R.CodeSmells) | $($R.Coverage)% | $($R.Duplications)% | $($R.QualityGate) |"
|
||||
}
|
||||
$Md -join "`n" | Out-File "$OutputDir\sonarqube-metrics.md" -Encoding UTF8
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "============================================================" -ForegroundColor Green
|
||||
Write-Host " FERTIG! $($Results.Count) Projekte analysiert" -ForegroundColor Green
|
||||
Write-Host " Ergebnisse in $OutputDir" -ForegroundColor Green
|
||||
Write-Host "============================================================" -ForegroundColor Green
|
||||
Reference in New Issue
Block a user