2016-07-27 147 views
2

嗨,大家好我想創建與碼頭工人和詹金斯管道和在執行npm install容器搬運工詹金斯DSL管道

$ 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/[email protected]:/home/jenkins/jenkins_slave/workspace/[email protected]: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安裝不好。

感謝, 豪爾赫

+1

這是怎麼涉及到[標籤:詹金斯在職DSL]標籤? – StephenKing

+0

那麼它與https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Pipeline+Plugin相關,這是jenkins-job-dsl的擴展,我猜想,這是我的新內容。如果你認爲這個標籤不合適,我可以改變它。謝謝 – jorgebo10

+1

感謝您的反饋。雖然_Pipeline_插件也使用DSL,但與[_Job DSL_](https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin)之一相比,它又是一個DSL。我刪除了標籤以防止混淆。 – StephenKing

回答

0

書面here

只是包裝你的舞臺有:

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