Commit 87bfa29e authored by wentao.suo's avatar wentao.suo

add sonar check pipeline

parent c2fb22f8
// src/org/foo/Stage.groovy
package org.qg.docker_new;
import org.qg.docker_new.Utils;
import groovy.json.JsonSlurperClassic;
def _utils() {
return new org.qg.docker_new.Utils();
}
def sonaar_check(){
_utils().beautyEcho("sonar check +++", "info")
/*
sonarScanner = "/home/quant_group/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar/bin/sonar-scanner"
currentPath = sh (script: 'pwd',returnStdout: true).trim()
git branch: "${GIT_BRANCH}", credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: "${GIT_PEPO_SSH_URL}"
sh "${sonarScanner} -e \
-Dsonar.host.url=http://172.30.3.42:9000 \
-Dsonar.projectVersion=${GIT_BRANCH} \
-Dsonar.projectKey=${GIT_BRANCH} \
-Dsonar.java.binaries=. \
-Dsonar.sources=. \
-Dsonar.projectBaseDir=${currentPath}"
*/
}
def callback_pipes(info) {
sleep 3
sonarInfo = sh (script: 'cat .sonar/report-task.txt |awk \`{printf $0 "&"}\'',returnStdout: true).trim()
items = sonarInfo.split("&")
for (def item : items){
echo item
}
/*callbackData = "${sonarReportTask}pipelineEntityId=aaa&taskNum=1"
echo "==========================="
echo callbackData
echo "==========================="
// def props = new Properties()
// props.load(sonarReportTask)
sh "curl --data ${callbackData} http://mock.q-gp.com"*/
}
def call(body) {
def _stage = new org.qg.ci.StageBucket()
def _utils = new org.qg.docker_new.Utils()
def GIT_PEPO_SSH_URL = env.GIT_PEPO_SSH_URL
def GIT_REPO_NAME = env.GIT_REPO_NAME
def GIT_BRANCH = env.GIT_BRANCH
def GIT_BRANCH_HASH = env.GIT_BRANCH_HASH
def GIT_TRIGER_USER = env.GIT_TRIGER_USER
def PIPELINE_ID = env.PIPELINE_ID
def STAGE_INDEX = env.STAGE_INDEX
def TASK_INDEX = env.TASK_INDEX
def info = [
pipline_id : PIPELINE_ID,
stage_index: STAGE_INDEX,
task_index: TASK_INDEX,
context:[]
]
ansiColor('xterm') {
echo "\033[32m############################################\n\
# GIT_PEPO_SSH_URL:${GIT_PEPO_SSH_URL}\n\
# GIT_REPO_NAME:${GIT_REPO_NAME}\n\
# GIT_BRANCH:${GIT_BRANCH}\n\
# GIT_BRANCH_HASH:${GIT_BRANCH_HASH}\n\
# GIT_TRIGER_USER:${GIT_TRIGER_USER}\n\
############################################\033[0m"
}
dir(gitRepoName){
node{
stage("SonarQube Quality Gate"){
def gitRepoName ="${GIT_REPO_NAME}"
}
stage("callback"){
_stage.callback_pipes(info)
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment