JK
This commit is contained in:
parent
20933ec47c
commit
9c38937e02
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
@ -119,34 +119,38 @@ pipeline {
|
|||||||
|
|
||||||
stage('SAST with SonarQube') {
|
stage('SAST with SonarQube') {
|
||||||
steps {
|
steps {
|
||||||
withSonarQubeEnv("${SONARQUBE_INSTANCE}") {
|
withSonarQubeEnv('SonarQube') {
|
||||||
sh '''
|
sh '''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
echo "=== SAST with SonarQube ==="
|
echo "=== SAST with SonarQube ==="
|
||||||
|
|
||||||
|
# Ensure scanner is available and PATH includes global tools
|
||||||
dotnet tool update --global dotnet-sonarscanner
|
dotnet tool update --global dotnet-sonarscanner
|
||||||
export PATH="$PATH:/root/.dotnet/tools"
|
export PATH="$PATH:/root/.dotnet/tools"
|
||||||
|
|
||||||
|
# BEGIN
|
||||||
dotnet sonarscanner begin \
|
dotnet sonarscanner begin \
|
||||||
/k:"${SONAR_PROJECT_KEY}" \
|
/k:AS400API \
|
||||||
/d:sonar.host.url="$SONAR_HOST_URL" \
|
/d:sonar.host.url=$SONAR_HOST_URL \
|
||||||
/d:sonar.login="$SONAR_AUTH_TOKEN" \
|
/d:sonar.login=$SONAR_AUTH_TOKEN \
|
||||||
/d:sonar.exclusions="**/bin/**,**/obj/**" \
|
/d:sonar.exclusions=**/bin/**,**/obj/** \
|
||||||
/d:sonar.test.exclusions="**/*.Tests/**"\
|
/d:sonar.test.exclusions=**/*.Tests/** \
|
||||||
/d:sonar.issue.ignore.multicriteria.e1.ruleKey="csharpsquid:S2068" \
|
/d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
|
||||||
/d:sonar.issue.ignore.multicriteria.e1.resourceKey="**/appsettings*.json"
|
|
||||||
|
|
||||||
dotnet clean -c Release
|
# BUILD & TEST (generate coverage if you want it on Sonar)
|
||||||
# สำคัญ: ปิด warnings-as-errors
|
dotnet restore
|
||||||
dotnet build -c Release -warnaserror:false -p:TreatWarningsAsErrors=false
|
dotnet build -c Release
|
||||||
|
dotnet test AS400API.Tests/AS400API.Tests.csproj -c Release \
|
||||||
|
/p:CollectCoverage=true \
|
||||||
|
/p:CoverletOutput=./TestResults/coverage/ \
|
||||||
|
/p:CoverletOutputFormat=\"opencover\"
|
||||||
|
|
||||||
|
# END (must be inside withSonarQubeEnv so it can create report-task.txt)
|
||||||
|
dotnet sonarscanner end /d:sonar.login=$SONAR_AUTH_TOKEN
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
// Optionally wait for Quality Gate
|
||||||
post {
|
// waitForQualityGate abortPipeline: true
|
||||||
always {
|
|
||||||
sh 'dotnet sonarscanner end /d:sonar.login="$SONAR_AUTH_TOKEN" || true'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user