1
votes

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:

enter image description here

2

2 Answers

0
votes

I had the same error. I don't know the reason of this error, but the workaround was using the non-alpine version of node. Maybe you could use a multistage docker build so your final image is based on alpine version anyway.

0
votes

I looked into this some more and I believe the issue is that there was an assumption of the presence of some dynamic dependencies that actually did not exist. Unfortunately I have moved onto another project and cannot recreate the issue but I suspect that if ldd is used, you will find that there are unsatisfied dynamic dependencies which cause the error. This also explains why the issue happens for alpine based images, by design they are meant to be lean and lightweight and likely do not include the dependencies.