我被困在与sonarqube集成的jenkins管道中我已经阅读了其他帖子,解决方案是更新耐用的插件;然而,我的插件是最新版本的v493.v195aefbb0ff2
控制台输出:
Injecting SonarQube environment variables using the configuration: sq1
[Pipeline] {
[Pipeline] sh
process apparently never started in /var/lib/jenkins/workspace/DevOps Demo@tmp/durable-48ce628f
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE
我的詹金斯档案如下
pipeline {
agent any
environment {
PATH = "/opt/maven"
BUILD_ID = 'BUILD_NUMBER'
}
stages {
stage('Get Code') {
steps {
echo 'Import code GitLab'
updateGitlabCommitStatus name: 'build', state: 'pending'
git branch: 'main', credentialsId: 'd6d909b7-d918-4ed3-b65f-426e3200a598', url: 'https://10.10.2.44/root/devops1.git'
echo 'build step goes here'
updateGitlabCommitStatus name: 'build', state: 'success'
}
}
stage('SonarQube analysis') {
steps {
withSonarQubeEnv(credentialsId: 'jenkins-sq', installationName: 'sq1') {
sh 'mvn sonar:sonar'
}
}
}
}
}
路径错误,必须包含docker jenkins的'/bin'。
environment {
PATH = "/opt/maven:/bin"
}
我也遇到了这个问题。首先,我升级了Jenkins耐用插件,在我的情况下,这个解决方案并没有解决这个问题。经过更深入的调查,我发现PATH变量是问题所在。请尝试在Jenkins环境中正确设置PATH变量。请确保可以在PATH上找到来自/bin位置的sh二进制文件。你可以运行";其中sh";查看sh二进制文件的确切位置。
environment {
PATH = "/bin:/usr/bin:usr/local/bin"
}