Hi I am trying to get Sonarqube to work with Jenkins. I have jenkins running as a docker image and Sonarqube server running as two separate docker images on my host machine. I am using the SonarScanner plugin for Jenkins to scan my project. However, when I try to run the my pipeline the "/var/jenkins_home/tools/hudson.plugins.sonar.SonarRunnerInstallation/test/bin/sonar-scanner" bash script returns the error could not find 'java' executable in JAVA_HOME or PATH
.
This is strange because I can successfully echo JAVA_HOME
within my Jenkins container. However, when I try to echo
within the bash script, it returns nothing. I also tried manually setting the JAVA_HOME variable within the script but found the script cant execute java. I also followed the advice from this post:
Jenkins pipeline for react could not find 'java' executable in JAVA_HOME or PATH
but it still does not work. Here is my Jenkins pipeline script
pipeline {
agent {
docker {
image 'node:6-alpine'
args '-p 3000:3000'
}
}
environment {
CI = 'true'
scannerHome = tool 'test'
}
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
stage('SonarQube analysis') {
agent{ docker { image 'openjdk' } }
steps{
withSonarQubeEnv('sonar') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
stage('Test') {
steps {
sh './jenkins/scripts/test.sh'
}
}
stage('Deliver') {
steps {
sh './jenkins/scripts/deliver.sh'
input message: 'Finished using the web site? (Click "Proceed" to continue)'
sh './jenkins/scripts/kill.sh'
}
}
}
}