这些是我的jenkins执行的日志:
> Step 1/2 : FROM tomcat:9.0.4-jre8-alpine
---> 631138bc037d
Step 2/2 : COPY /Fatcat-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/fatcat.war
---> Using cache
---> 700d13ec5fb5
Successfully built 700d13ec5fb5
>
> [Pipeline] dockerFingerprintFrom
>
> [Pipeline] }
>
> [Pipeline] // stage
>
> [Pipeline] sh
>
> [unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA]
> Running shell script
>
> + docker inspect -f . 3bf1d418c6b61a03e2f2abe9d37b4c5e759e0b0a
>
> . [Pipeline] withDockerContainer Jenkins does not seem to be running
> inside a container
>
> $ docker run -t -d -u 1000:1000 -w /data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA
> -v /data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA:/data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA:rw,z
> -v /data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA@tmp:/data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA@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 ******** 3bf1d418c6b61a03e2f2abe9d37b4c5e759e0b0a cat
> $ docker top f3826ded71315b33b4d352ac2181035655f73d58a7c998040db36b6d664f1421 -eo
> pid,comm
>
> [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] sh
> [unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA]
> Running shell script
> + node --version /data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA@tmp/durable-f0e86b83/script.sh:
> line 1: node: Permission denied [Pipeline] }enter code here [Pipeline]
> // stage [Pipeline] }
> `$ docker stop --time=1`
> f3826ded71315b33b4d352ac2181035655f73d58a7c998040db36b6d664f1421
>
> $ docker rm -f f3826ded71315b33b4d352ac2181035655f73d58a7c998040db36b6d664f1421
>
> [Pipeline] // withDockerContainer [Pipeline] } [Pipeline] // node
> [Pipeline] End of Pipeline ERROR: script returned exit code 127
> Finished: FAILURE
问题出在这一行:
> [unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA] Running shell script
>
> + node --version
>
> > /data/jenkins_ws/unFatCat_master-RSJASSVAHZJXKMANQQZOIIGTV3YC2D2GJS65WJ23OAY3WGXOVRJA@tmp/durable-f0e86b83/script.sh:
> > line 1: node: Permission denied
我想使用本地ad-hoc Docker。这是Dockerfile:
FROM node:7-alpine
FROM tomcat:9.0.4-jre8-alpine
COPY /Fatcat-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/fatcat.war
注意我在Docker中加载了节点:7-alpine 而不是在Jenkins配置中
这是我的Jenkins文件:
pipeline {
agent { dockerfile true }
stages {
stage('Test') {
steps {
sh 'node --version'
sh 'mvn --version'
}
}
}
}
我在Jenkins中安装了Nodejs插件。
这是我的问题:
node --version
未执行?node --version
未在容器内执行吗?我已经检查了此link的权限被拒绝错误。但是,分区是使用exec参数安装的。所以建议的解决方案对我无效。
答案 0 :(得分:0)
以下面的格式更改您的Jenkins Declaritive管道。希望你能得到结果。
pipeline {
agent {
docker {
image 'maven:3-alpine'
image 'node:7-alpine'
}
}
stages {
stage('Test') {
steps {
sh 'node --version'
sh 'mvn --version'
}
}
}
}