我有一个 jenkins 管道来检查、构建和部署一个反应项目。
pipeline {
agent {
docker {
image 'node:6-alpine'
args '-v /home/nginx/console:/home/'
args '-p 3000:3000'
}
}
environment {
CI = 'true'
}
stages {
stage('Install') {
steps {
sh 'touch /tmp/azeiodfsihqznlkdsqjfn'
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Deploy') {
steps {
sh 'ls'
sh '$(pwd)'
}
}
}
}
我想将/home
容器的文件夹与/home/nginx/console
主机上的目录一起挂载。构建后,在容器内,我会将dist/*
内容移动到 /home 以便将其放入/home/nginx/console
但似乎没有安装该卷。当我在 /home 中创建文件时,我的主机中没有任何内容。
编辑:在我的控制台日志中,我有:
Checking out Revision 3471c656f032692288de13f357c4b8ba54b16ca4 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 3471c656f032692288de13f357c4b8ba54b16ca4
Commit message: "Update Jenkinsfile"
> git rev-list --no-walk c5930fc469fd066720df45cdf466788957cdb0bc # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . node:6-alpine
.
[Pipeline] withDockerContainer
Jenkins seems to be running inside container 1ce58d845edf831599312c3d016c418a720891ea17c7bacd8327c48f9c44e9f6
$ docker run -t -d -u 0:0 -p 3000:3000 -w /var/jenkins_home/workspace/gara-developer-console --volumes-from 1ce58d845edf831599312c3d016c418a720891ea17c7bacd8327c48f9c44e9f6 -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 ******** node:6-alpine cat
$ docker top 2fe2bdef3f475373cf85dfd452b6bbda21bc02dc308458ffff061b0ae9e963ec -eo pid,comm
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Install)
[Pipeline] sh
+ touch /home/azeiodfsihqznlkdsqjfn
[Pipeline] sh
+ npm install
请问,你知道我该如何纠正吗?