enh(chore): integrate sonarQube dev edition (#2937)
This commit is contained in:
parent
dbce757df2
commit
3dbfcab903
|
@ -1,3 +1,5 @@
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
properties([buildDiscarder(logRotator(numToKeepStr: '50'))])
|
properties([buildDiscarder(logRotator(numToKeepStr: '50'))])
|
||||||
|
|
||||||
stage('Source') {
|
stage('Source') {
|
||||||
|
@ -10,15 +12,48 @@ stage('Source') {
|
||||||
source = readProperties file: 'source.properties'
|
source = readProperties file: 'source.properties'
|
||||||
env.VERSION = "${source.VERSION}"
|
env.VERSION = "${source.VERSION}"
|
||||||
env.RELEASE = "${source.RELEASE}"
|
env.RELEASE = "${source.RELEASE}"
|
||||||
if (env.BRANCH_NAME == 'master') {
|
// Run sonarQube analysis
|
||||||
withSonarQubeEnv('SonarQube') {
|
withSonarQubeEnv('SonarQubeDev') {
|
||||||
sh './centreon-build/jobs/plugins/plugins-analysis.sh'
|
sh './centreon-build/jobs/plugins/plugins-analysis.sh'
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
stage('Quality gate') {
|
||||||
|
node {
|
||||||
|
def reportFilePath = "target/sonar/report-task.txt"
|
||||||
|
def reportTaskFileExists = fileExists "${reportFilePath}"
|
||||||
|
if (reportTaskFileExists) {
|
||||||
|
echo "Found report task file"
|
||||||
|
def taskProps = readProperties file: "${reportFilePath}"
|
||||||
|
echo "taskId[${taskProps['ceTaskId']}]"
|
||||||
|
timeout(time: 10, unit: 'MINUTES') {
|
||||||
|
while (true) {
|
||||||
|
sleep 10
|
||||||
|
def taskStatusResult =
|
||||||
|
sh(returnStdout: true, script: "curl -s -X GET -u ${authString} \'${sonarProps['sonar.host.url']}/api/ce/task?id=${taskProps['ceTaskId']}\'")
|
||||||
|
echo "taskStatusResult[${taskStatusResult}]"
|
||||||
|
def taskStatus = new JsonSlurper().parseText(taskStatusResult).task.status
|
||||||
|
echo "taskStatus[${taskStatus}]"
|
||||||
|
// Status can be SUCCESS, ERROR, PENDING, or IN_PROGRESS. The last two indicate it's
|
||||||
|
// not done yet.
|
||||||
|
if (taskStatus != "IN_PROGRESS" && taskStatus != "PENDING") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
def qualityGate = waitForQualityGate()
|
||||||
|
if (qualityGate.status != 'OK') {
|
||||||
|
currentBuild.result = 'FAIL'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
|
||||||
|
error("Quality gate failure: ${qualityGate.status}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stage('Package') {
|
stage('Package') {
|
||||||
parallel 'all': {
|
parallel 'all': {
|
||||||
node {
|
node {
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
sonar.projectKey=centreon-plugins
|
# project
|
||||||
sonar.projectName=Centreon Plugins
|
sonar.projectKey={PROJECT_TITLE}
|
||||||
|
sonar.projectName={PROJECT_NAME}
|
||||||
|
sonar.projectVersion={PROJECT_VERSION}
|
||||||
sonar.sources=.
|
sonar.sources=.
|
||||||
|
|
||||||
|
sonar.tsql.file.suffixes=sql,tsql
|
||||||
|
sonar.plsql.file.suffixes=pks,pkb
|
||||||
|
|
||||||
|
# mandatory to not fail the builds until build-wrapper is installed and sources are compiled
|
||||||
|
sonar.c.file.suffixes=-
|
||||||
|
sonar.cpp.file.suffixes=-
|
||||||
|
sonar.objc.file.suffixes=-
|
||||||
|
|
Loading…
Reference in New Issue