我正在运行詹金斯管道。在最后一步,我的声纳分析引发了一个错误:
var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner/bin/sonar-scanner
Could not find 'java' executable in JAVA_HOME or PATH.
我在centos 7中设置了JAVA_HOME,当我运行echo $ JAVA_HOME时,我得到了:
echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
错误在声纳扫描仪中引发:
if [ -n "$JAVA_HOME" ]
then
java_cmd="$JAVA_HOME/bin/java"
else
java_cmd="$(which java)"
fi
java_cmd="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre/bin/java"
echo $java_cmd
#export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
if [ -z "$java_cmd" -o ! -x "$java_cmd" ] ; then
echo "Could not find 'java' executable in JAVA_HOME or PATH."
exit 1
fi
我尝试了许多解决方案,但仍然遇到相同的错误,请问,我可以纠正它吗?
我的詹金斯管道脚本:
pipeline {
agent {
docker {
image 'node:6-alpine'
args '-v /home/nginx/console:/home -p 3000:3000'
}
}
environment {
CI = 'true'
}
stages {
stage('Install') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Deploy') {
steps {
sh 'cp -R dist/* /home'
}
}
stage('Sonarqube analysis') {
steps {
script {
scannerHome = tool 'SonarQube Scanner';
}
withSonarQubeEnv('sonar') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
}
答案 0 :(得分:0)
基于yong的要求,我创建了这个jenkinsfile并成功进行了声纳测试:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Summary Year="2019" Month="08" Number="1" TotalQty="4" TotalAmt="50" TotalDisc="7"/>
</Root>