title: TypeScript SonarQube Scan in Docker Container
body: <p>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.</p>
  
  <p>The Dockerfile for my container is:</p>
  
  <pre><code>FROM node:7-alpine
  
  RUN npm install -g gulp sonarqube-scanner 
  </code></pre>
  
  <p>My Jenkins file looks like:</p>
  
  <pre><code>pipeline {
     agent {
        dockerfile { dir 'build-image' }
     }
      stages {
          stage('Build') {
              steps {
                    sh 'npm install'
                    sh 'npm run build'
              }       
          }
          stage("SonarQube Analysis") {
             steps{
                sh 'gulp sonar'
             }
          }
  </code></pre>
  
  <p>Everything seems to be ok until sonar is run. When it runs I get the error:</p>
  
  <blockquote>
    <p>[-47-get-web-client-building-LUNCQQ5SQOUXXUXPT5TJDVBCFON3OPD2COBIW6WPU3J3ZRFFTYJQ] Running shell script</p>
    
    <ul>
    <li>gulp sonar</li>
    </ul>
    
    <p>[03:00:14] Using gulpfile
    /var/jenkins_home/workspace/-47-get-web-client-building-LUNCQQ5SQOUXXUXPT5TJDVBCFON3OPD2COBIW6WPU3J3ZRFFTYJQ/gulpfile.js</p>
    
    <p>[03:00:14] Starting 'sonar'...</p>
    
    <p>[03:00:14] Starting SonarQube analysis...</p>
    
    <p>[03:00:14] Checking if executable exists:
    /home/node/.sonar/native-sonar-scanner/sonar-scanner-3.0.3.778-linux/bin/sonar-scanner</p>
    
    <p>[03:00:14] Could not find executable in
    '/home/node/.sonar/native-sonar-scanner'.</p>
    
    <p>[03:00:14] Proceed with download of the platform binaries for
    SonarQube Scanner...</p>
    
    <p>[03:00:14] Creating /home/node/.sonar/native-sonar-scanner</p>
    
    <p>[03:00:14] Downloading from
    <a href="https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778-linux.zip" rel="nofollow noreferrer">https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778-linux.zip</a></p>
    
    <p>[03:00:14] (executable will be saved in cache folder:
    /home/node/.sonar/native-sonar-scanner)</p>
    
    <p>/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</p>
    
    <p>child_process.js:504</p>
  
  <pre><code>throw err;
  
  ^
  </code></pre>
  </blockquote>
  
  <p>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:</p>
  
  <p><a href="https://i.stack.imgur.com/NOboo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NOboo.png" alt="enter image description here"></a></p>