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

Declarative: Steps don't run inside container with "dockerfile true"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker-workflow-plugin
    • Jenkins 2.121.1
      Docker Pipeline 1.17

      Container image is built and executed correctly but step commands run outside container.

      Jenkins 2.121.1 (running as a systemd unit on master and a remote build node through SSH Slave plugin)
      Docker Pipeline plugin 1.17 (released in May 2018)
      Docker CE 18.03 running on CentOS 7.5
       

      pipeline {
          agent { dockerfile true }
          stages {
              stage('Test') {
                  steps {
                      sh 'cd /app && npm test'
                  }
              }
          }
      } 

      And then the test stage doesn't run inside the Docker container that was started:

      [Pipeline] withDockerContainer
      ci-node does not seem to be running inside a container
      $ docker run -t -d -u 1020:1020 -w /home/jenkins/workspace/gpii-express_PR-7-something -v /home/jenkins/workspace/gpii-express_PR-7-something:/home/jenkins/workspace/gpii-express_PR-7-something:rw,z -v /home/jenkins/workspace/gpii-express_PR-7-something@tmp:/home/jenkins/workspace/gpii-express_PR-7-something@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** 1d0c4aca5306042f527e42c2e15dd885f78a0ac3 cat
      $ docker top 9d555195979c311991213dbcc0ef367c66b86972ba8deeb44322b122b2c02c41 -eo pid,comm
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Test)
      [Pipeline] sh
      [gpii-express_PR-7-something] Running shell script
      + cd /app
      + npm test
      
      > gpii-express@1.0.15 pretest /app
      > node node_modules/rimraf/rimraf coverage/* reports/*
      
      
      > gpii-express@1.0.15 test /app
      > node node_modules/istanbul/lib/cli.js cover tests/all-tests.js --print summary
      
      /app/node_modules/mkdirp/index.js:90
                          throw err0;
                          ^
      
      Error: EACCES: permission denied, mkdir '/app/reports'
          at Object.mkdirSync (fs.js:738:3)
          at Function.sync (/app/node_modules/mkdirp/index.js:71:13)
          at Object.run (/app/node_modules/istanbul/lib/command/common/run-with-cover.js:129:16)
          at CoverCommand.run (/app/node_modules/istanbul/lib/command/cover.js:27:22)
          at runCommand (/app/node_modules/istanbul/lib/cli.js:83:19)
          at runToCompletion (/app/node_modules/istanbul/lib/cli.js:87:5)
          at Object.<anonymous> (/app/node_modules/istanbul/lib/cli.js:93:5)
          at Module._compile (internal/modules/cjs/loader.js:702:30)
          at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
          at Module.load (internal/modules/cjs/loader.js:612:32)
      npm ERR! Test failed.  See above for more details.
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      $ docker stop --time=1 9d555195979c311991213dbcc0ef367c66b86972ba8deeb44322b122b2c02c41
      $ docker rm -f 9d555195979c311991213dbcc0ef367c66b86972ba8deeb44322b122b2c02c41
      [Pipeline] // withDockerContainer
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      

      Running the Docker image that Jenkins built works just fine:

      $ docker run --rm -ti 1d0c4aca5306042f527e42c2e15dd885f78a0ac3 /bin/sh
      /app $ npm test
      
      > gpii-express@1.0.15 pretest /app
      > node node_modules/rimraf/rimraf coverage/* reports/*
      
      
      > gpii-express@1.0.15 test /app
      > node node_modules/istanbul/lib/cli.js cover tests/all-tests.js --print summary
      ...
      16:53:58.388:  jq: ***************
      16:53:58.388:  jq: All tests concluded: 167/167 total passed in 15718ms - PASS
      16:53:58.389:  jq: ***************
      /app $ exit
      

            Unassigned Unassigned
            gtirloni Giovanni Tirloni
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: