This commit is contained in:
Anupong Hompan 2025-10-25 21:52:18 +07:00
parent 4fe54e8bc7
commit fa4dadc8ba

21
Jenkinsfile vendored
View File

@ -130,32 +130,35 @@ pipeline {
dotnet tool update --global dotnet-sonarscanner
export PATH="$PATH:/root/.dotnet/tools"
# BEGIN
# Optional: show Java & reachability
java -version || true
curl -sf "$SONAR_HOST_URL/api/system/health" || { echo "Cannot reach SonarQube at $SONAR_HOST_URL"; exit 1; }
# BEGIN (use injected URL/token; add verbose for diagnostics)
dotnet sonarscanner begin \
/k:AS400API \
/d:sonar.host.url=$SONAR_HOST_URL \
/d:sonar.login=$SONAR_AUTH_TOKEN \
/d:sonar.verbose=true \
/d:sonar.exclusions=**/bin/**,**/obj/** \
/d:sonar.test.exclusions=**/*.Tests/** \
/d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
# BUILD & TEST (generate coverage if you want it on Sonar)
# BUILD & TEST (produce OpenCover report)
dotnet restore
dotnet build -c Release
dotnet test AS400API.Tests/AS400API.Tests.csproj -c Release \
/p:CollectCoverage=true \
/p:CoverletOutput=./TestResults/coverage/ \
/p:CoverletOutputFormat=\"opencover\"
/p:CoverletOutputFormat=opencover
# END (must be inside withSonarQubeEnv so it can create report-task.txt)
dotnet sonarscanner end /d:sonar.login=$SONAR_AUTH_TOKEN
# END (no login flag; uses env from withSonarQubeEnv)
dotnet sonarscanner end /d:sonar.verbose=true
'''
}
// Optionally wait for Quality Gate
// Optionally wait for the Quality Gate (only if 'end' succeeds)
// waitForQualityGate abortPipeline: true
}
}
stage('Test + Coverage') {
steps {
sh '''