docker jenkins dsl管道

jorgebo10

嗨,大家好,我正在尝试使用docker和jenkins创建管道,并且npm install在容器内执行时遇到以下错误

$ docker run -t -d -u 1001:1001 -w 
/home/jenkins/jenkins_slave/workspace/SistacLabAPI -v /home/jenkins/jenkins_slave/workspace/SistacLabAPI:/home/jenkins/jenkins_slave/workspace/SistacLabAPI:rw -v /home/jenkins/jenkins_slave/workspace/SistacLabAPI@tmp:/home/jenkins/jenkins_slave/workspace/SistacLabAPI@tmp:rw jorgebo10/slapi:jenkins-SistacLabAPI-125 cat
[Pipeline] {
[Pipeline] sh
[SistacLabAPI] Running shell script
+ pwd
/home/jenkins/jenkins_slave/workspace/SistacLabAPI
[Pipeline] sh
[SistacLabAPI] Running shell script
+ ls -l
total 280
-rw-rw-r-- 1 1001 1001    316 Jul 26 23:06 Dockerfile
-rw-rw-r-- 1 1001 1001   1331 Jul 26 19:27 Gruntfile.js
-rw-rw-r-- 1 1001 1001  11357 Jul 26 19:27 LICENSE
drwxrwxr-x 4 1001 1001   4096 Jul 26 19:27 app
-rw-rw-r-- 1 1001 1001    926 Jul 26 19:27 app.js
drwxrwxr-x 3 1001 1001   4096 Jul 26 19:27 config
drwxr-xr-x 2 1001 1001   4096 Jul 27 15:29 jorge
-rw-r--r-- 1 1001 1001 240093 Jul 27 15:28 npm-debug.log
-rw-rw-r-- 1 1001 1001   1348 Jul 26 19:27 package.json
drwxrwxr-x 2 1001 1001   4096 Jul 26 19:27 public
[Pipeline] sh
[SistacLabAPI] Running shell script
+ hostname
61162ea48f0b
[Pipeline] sh
[SistacLabAPI] Running shell script
+ node -v
v4.4.7
[Pipeline] sh
[SistacLabAPI] Running shell script
+ npm install
npm ERR! Linux 3.13.0-92-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.4.7
npm ERR! npm  v2.15.8
npm ERR! path /.npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/.npm'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/.npm']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/.npm',
npm ERR!   parent: 'sistacLabAPI' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/jenkins/jenkins_slave/workspace/SistacLabAPI/npm-debug.log
[Pipeline] }
$ docker stop 61162ea48f0b6044cf3b1b9d763d1b098b21af87b152901c64610df4b0060c22
$ docker rm -f 61162ea48f0b6044cf3b1b9d763d1b098b21af87b152901c64610df4b0060c22

我的詹金斯文件包含以下内容

node('docker') {
    git url: 'https://github.com/jorgebo10/SistacLabAPI.git', branch:'development'

    docker.build("jorgebo10/slapi:${env.BUILD_TAG}").inside {
        sh "pwd"
        sh "ls -l"
        sh "hostname"
        sh "node -v"
        sh "npm install"
    }

    input '¿Deploy to production?'

    stage 'Production'
}

关于可能发生什么的任何线索?似乎以用户1001的身份运行npm install不好。

谢谢,豪尔赫

用户名

作为书面这里

只需用以下步骤结束您的舞台:

withEnv(['HOME=.']) {
... 
...
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章