Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43594

Job kills "npm install" that stuck in preinstall step

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Blocker Blocker
    • pipeline
    • Jenkins 2.46.1 in Docker on AWS EC2 t2.medium instance with Amazon Linux (amd64, 4.4.19-29.55.amzn1.x86_64)

      Node JS 6.10.2, npm 3.10.10
      nodejs plugin 1.2.0

      The only master is used to run jobs

      Jenkins docker-compose:

      version: '2'
      services:
        jenkins:
          cpu_shares: 512
          image: jenkins:2.46.1
          mem_limit: 2g
          ports:
          - 80:8080
          - 50000:50000
          privileged: true
          user: root
          volumes:
          - /home/ec2-user/jenkins_home:/var/jenkins_home
          - /var/run/docker.sock:/var/run/docker.sock
          - /usr/bin/docker:/usr/local/bin/docker
          - /lib64/libdevmapper.so.1.02:/usr/lib/libdevmapper.so.1.02
          - /lib64/libudev.so.0:/usr/lib/libudev.so.0
          - /home/ec2-user/.m2:/root/.m2
      

      Job configuration:

      #!groovy
      
      node {
          timeout(20 /* minutes */) {
              // Need to replace the '%2F' used by Jenkins to deal with / in the path (e.g. story/...)
              // because tests that do getResource will escape the % again, and the test files can't be found.
              // See https://issues.jenkins-ci.org/browse/JENKINS-34564 for more.
              ws("workspace/${env.JOB_NAME}") {
                  stage('Checkout') {
                      checkout scm
                  }
      
                  stage('Build') {
                      parallel api: {
                          mvn 'clean install -DskipTests -Pprod'
                          archiveToS3 'api/target/api*-standalone.jar'
                      }, web: {
                          dir('frontend') {
                              npm 'install -d'
      
                              npm 'run build-web'
                              dir('web-react/build') {
                                  sh "tar zcf ../../web.tar.gz ./*"
                              }
      
                              archiveToS3 'web.tar.gz'
                          }
                      }, failFast: true
                  }
      ...
      
      def npm(args) {
          nodejs(nodeJSInstallationName: 'node6LTS') {
              sh "npm $args"
          }
      }

      Job stuck on the stepĀ 

      npm 'install -d'

      After some time (less than 20 minutes) the job fails with the log like this

      ...
      [web] npm info attempt registry request try #1 at 5:43:32 AM
      [web] npm http request GET https://registry.npmjs.org/http-errors
      [web] npm http 304 https://registry.npmjs.org/http-errors
      [web] npm info lifecycle <my-project-name>@1.2.1~preinstall: <my-project-name>@1.2.1
      [web] Killed
      [Pipeline] [web] }
      [Pipeline] [web] // wrap
      [Pipeline] [web] }
      [Pipeline] [web] // dir
      [Pipeline] [web] }
      [web] Failed in branch web
      [Pipeline] // parallel
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // ws
      [Pipeline] }
      [Pipeline] // timeout
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      ERROR: script returned exit code 137
      Finished: FAILURE
      

      This behavior I encountered with Jenkins 2.19.4 after some plugins updates (about 7 April). Even after migration to Jenkins 2.46.1 I have the same issue.

      When I run the same command manually locally or on the same Jenkins job workspace it works well. I don't know if it is related to NodeJs plugin, or any other plugins, or Jenkins itself.

      Sometimes it works but it is a very rare case about 1 from 30 executions.

      P.S.:

      It is a blocker for us. Any hint or workaround is appreciated.

            Unassigned Unassigned
            abeletsky Andrey Beletsky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: