【发布时间】:2021-06-01 15:51:16
【问题描述】:
从这个https://www.jenkins.io/doc/book/pipeline/docker/我想传递一个特定的dockerfile路径。
$jenkins_home/workspace/<project>下的目录结构
├── dockerfiles
├── hello
│ └── Dockerfile
├── Jenkinsfile
jenkinsfile 中的内容是这样的
stage('Build Image') {
steps {
script {
def dockerfile = "Dockerfile.${env.branchName}"
def dockerImage = docker.build("${imageName}" + ":" + "${imageTag}", "-f ${dockerfile} ./dockerfiles")
}
}
}
导致这个错误
+ docker build -t localhost:32000/hello:feature -f Dockerfile.hello ./dockerfiles
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/jenkins_home/workspace/simple_project/Dockerfile.hello: no such file or directory
【问题讨论】:
-
就像错误消息说的那样,它不喜欢符号链接,特别是出于安全原因,指向当前目录之外的任何内容的符号链接。
-
@BTH.S3 我提供的解决方案对你有用吗
标签: docker jenkins jenkins-pipeline jenkins-groovy