npm install fails in jenkins pipeline in docker

前端 未结 12 927
野性不改
野性不改 2020-12-07 17:45

I\'m following a tutorial about Jenkins pipeline and I can get a \"hello world\" working under at node 6.10 docker container.

But, when I added a default EmberJS app

12条回答
  •  情话喂你
    2020-12-07 18:08

    When Jenkins runs the stage in Docker agent it usually sets HOME=/ (image WORKDIR value), but Jenkins user does not have write permissions in this directory, that's why npm cannot create its cache directory ~/.npm. To solve this you need either to override HOME or NPM default cache directory:

    environment {
        // Override HOME to WORKSPACE
        HOME = "${WORKSPACE}"
        // or override default cache directory (~/.npm)
        NPM_CONFIG_CACHE = "${WORKSPACE}/.npm"
    }
    

提交回复
热议问题