I am trying to build my TypeScript application through a Jenkins pipeline. To manage the build, test and code quality scan I am having Jenkins use a Docker agent based on node:7-alpine.
The Dockerfile for my container is:
FROM node:7-alpine
RUN npm install -g gulp sonarqube-scanner
My Jenkins file looks like:
pipeline {
agent {
dockerfile { dir 'build-image' }
}
stages {
stage('Build') {
steps {
sh 'npm install'
sh 'npm run build'
}
}
stage("SonarQube Analysis") {
steps{
sh 'gulp sonar'
}
}
Everything seems to be ok until sonar is run. When it runs I get the error:
[-47-get-web-client-building-LUNCQQ5SQOUXXUXPT5TJDVBCFON3OPD2COBIW6WPU3J3ZRFFTYJQ] Running shell script
- gulp sonar
[03:00:14] Using gulpfile /var/jenkins_home/workspace/-47-get-web-client-building-LUNCQQ5SQOUXXUXPT5TJDVBCFON3OPD2COBIW6WPU3J3ZRFFTYJQ/gulpfile.js
[03:00:14] Starting 'sonar'...
[03:00:14] Starting SonarQube analysis...
[03:00:14] Checking if executable exists: /home/node/.sonar/native-sonar-scanner/sonar-scanner-3.0.3.778-linux/bin/sonar-scanner
[03:00:14] Could not find executable in '/home/node/.sonar/native-sonar-scanner'.
[03:00:14] Proceed with download of the platform binaries for SonarQube Scanner...
[03:00:14] Creating /home/node/.sonar/native-sonar-scanner
[03:00:14] Downloading from https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778-linux.zip
[03:00:14] (executable will be saved in cache folder: /home/node/.sonar/native-sonar-scanner)
/home/node/.sonar/native-sonar-scanner/sonar-scanner-3.0.3.778-linux/bin/sonar-scanner: exec: line 73: /home/node/.sonar/native-sonar-scanner/sonar-scanner-3.0.3.778-linux/jre/bin/java: not found
child_process.js:504
throw err; ^
I have played around with just the node:7-alpine container and I get the same error. What's odd is that the container has the java executable but it does not seem to be recognized:
