2021-07-06 10:14:28 +02:00
|
|
|
import groovy.json.JsonSlurper
|
|
|
|
|
2020-04-21 09:20:09 +02:00
|
|
|
properties([buildDiscarder(logRotator(numToKeepStr: '50'))])
|
|
|
|
|
2018-11-02 11:57:18 +01:00
|
|
|
stage('Source') {
|
|
|
|
node {
|
|
|
|
sh 'setup_centreon_build.sh'
|
|
|
|
dir('centreon-plugins') {
|
|
|
|
checkout scm
|
|
|
|
}
|
|
|
|
sh './centreon-build/jobs/plugins/plugins-source.sh'
|
|
|
|
source = readProperties file: 'source.properties'
|
|
|
|
env.VERSION = "${source.VERSION}"
|
|
|
|
env.RELEASE = "${source.RELEASE}"
|
2021-07-06 10:14:28 +02:00
|
|
|
// Run sonarQube analysis
|
|
|
|
withSonarQubeEnv('SonarQubeDev') {
|
|
|
|
sh './centreon-build/jobs/plugins/plugins-analysis.sh'
|
2018-12-10 11:38:29 +01:00
|
|
|
}
|
2018-11-02 11:57:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2021-07-06 10:14:28 +02:00
|
|
|
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}.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 11:57:18 +01:00
|
|
|
stage('Package') {
|
2018-11-07 13:55:01 +01:00
|
|
|
parallel 'all': {
|
2018-11-02 11:57:18 +01:00
|
|
|
node {
|
|
|
|
sh 'setup_centreon_build.sh'
|
2018-11-07 13:55:01 +01:00
|
|
|
sh './centreon-build/jobs/plugins/plugins-package.sh'
|
2018-11-02 11:57:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
|
|
|
|
error('Package stage failure.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
if (env.BRANCH_NAME == 'master') {
|
|
|
|
slackSend channel: "#monitoring-metrology", color: "#F30031", message: "*FAILURE*: `CENTREON PLUGINS` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n*COMMIT*: <https://github.com/centreon/centreon-plugins/commit/${source.COMMIT}|here> by ${source.COMMITTER}\n*INFO*: ${e}"
|
|
|
|
}
|
|
|
|
}
|