admin管理员组文章数量:1294707
i have jenkins config for setting up integrate from jenkins to sonarqube `
// Stage to check SonarQube task status
stage('Check SonarQube Task Status') {
steps {
script {
// Poll the SonarQube API for task status
def taskId = getSonarQubeTaskId() // Function to fetch the task ID from the previous stage
def taskStatus = getSonarQubeTaskStatus(taskId) // Function to fetch task status
// If the task status is not 'SUCCESS', abort the pipeline
if (taskStatus != 'SUCCESS') {
error "SonarQube scan failed. Aborting pipeline!"
} else {
echo "SonarQube scan passed. Continuing pipeline."
}
}
}
// Function to get the SonarQube task status using the API
def getSonarQubeTaskStatus(taskId) {
def sonarApiUrl = "${env.SONARQUBE_SERVER}/api/ce/task?id=${taskId}"
def response = httpRequest(url: sonarApiUrl, authentication: 'sonar-token') // Use your authentication method here
def jsonResponse = readJSON text: response
return jsonResponse.task.status
}
I have tried to get status from my sonarqube on jenkins. but i cannot get that... when i check on my sonarqube status my code already passed
but when i check on jenkins i got error ERROR: Failed to extract SonarQube Task ID from scanner output Finished: FAILURE
my code is using golang and deploy on ec2
how to fix this issue ?
my expecting is my code can running the others process such as
stage('Build Docker Image') {
steps {
sh 'docker build -t $GITLAB_REGISTRY/$IMAGE_NAME:latest .'
}
}
stage('Login to GitLab Registry') {
steps {}
how to fix this issue ?
i have jenkins config for setting up integrate from jenkins to sonarqube `
// Stage to check SonarQube task status
stage('Check SonarQube Task Status') {
steps {
script {
// Poll the SonarQube API for task status
def taskId = getSonarQubeTaskId() // Function to fetch the task ID from the previous stage
def taskStatus = getSonarQubeTaskStatus(taskId) // Function to fetch task status
// If the task status is not 'SUCCESS', abort the pipeline
if (taskStatus != 'SUCCESS') {
error "SonarQube scan failed. Aborting pipeline!"
} else {
echo "SonarQube scan passed. Continuing pipeline."
}
}
}
// Function to get the SonarQube task status using the API
def getSonarQubeTaskStatus(taskId) {
def sonarApiUrl = "${env.SONARQUBE_SERVER}/api/ce/task?id=${taskId}"
def response = httpRequest(url: sonarApiUrl, authentication: 'sonar-token') // Use your authentication method here
def jsonResponse = readJSON text: response
return jsonResponse.task.status
}
I have tried to get status from my sonarqube on jenkins. but i cannot get that... when i check on my sonarqube status my code already passed
but when i check on jenkins i got error ERROR: Failed to extract SonarQube Task ID from scanner output Finished: FAILURE
my code is using golang and deploy on ec2
how to fix this issue ?
my expecting is my code can running the others process such as
stage('Build Docker Image') {
steps {
sh 'docker build -t $GITLAB_REGISTRY/$IMAGE_NAME:latest .'
}
}
stage('Login to GitLab Registry') {
steps {}
how to fix this issue ?
Share Improve this question edited Feb 12 at 11:48 Reporter 3,9485 gold badges35 silver badges49 bronze badges asked Feb 12 at 11:43 jujil lololojujil lololo 32 bronze badges2 Answers
Reset to default 0Can you try below config. it may be helpful as i know.
This is for extracting the taskid correctly
def getSonarQubeTaskStatus(taskId) {
def sonarApiUrl = "${env.SONARQUBE_SERVER}/api/ce/task?id=${taskId}"
echo "Fetching SonarQube task status from: ${sonarApiUrl}"
def response = httpRequest(url: sonarApiUrl, authentication: 'sonar-token')
echo "SonarQube API Response: ${response.content}"
def jsonResponse = readJSON text: response.content
return jsonResponse.task.status
}
and below is for checking the task status.
def getSonarQubeTaskStatus(taskId) {
def sonarApiUrl = "${env.SONARQUBE_SERVER}/api/ce/task?id=${taskId}"
echo "Fetching SonarQube task status from: ${sonarApiUrl}"
def response = httpRequest(url: sonarApiUrl, authentication: 'sonar-token')
echo "SonarQube API Response: ${response.content}"
def jsonResponse = readJSON text: response.content
return jsonResponse.task.status
}
Check Plugins: Ensure Jenkins has the SonarQube Scanner plugin installed.
Configure SonarQube: Add SonarQube server details in Jenkins (Manage Jenkins > Configure System).
Scanner Setup: Install the SonarQube Scanner in Jenkins (Global Tool Configuration).
Add Step: In your Jenkins job, add a "Execute SonarQube Scanner" build step.
Check Logs: If it fails, check Jenkins logs for errors.
本文标签: Issueing when integrate jenkins with sonarqube scannerStack Overflow
版权声明:本文标题:Issueing when integrate jenkins with sonarqube scanner - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741603234a2387823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论