By using jenkins, I create an item of "Pipeline" type. And I set "Pipeline from SCM" to get Jenkinsfile. You can check my GitHub repository:
I want use Jenkins pipeline to build a docker image. Here is the Jenkinsfile:
node { sh "docker build -t 192.168.59.224:5000/ubuntu-test ." } The Dockerfile is also very simple:
FROM ubuntu:14.04 RUN sudo apt-get update && sudo apt-get install -y wget When I run the project. I got following error:
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/jenkins_home/workspace/test/Dockerfile: no such file or directory Here is the full console output
Started by user kai [Pipeline] node Running on master in /var/jenkins_home/workspace/test [Pipeline] { [Pipeline] sh [test] Running shell script + docker build -t 192.168.59.224:5000/ubuntu-test . unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/jenkins_home/workspace/test/Dockerfile: no such file or directory [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1 Finished: FAILURE I checked the workspace:
ls /var/jenkins_home/workspace/test/ ls /var/jenkins_home/workspace/test@script/ Dockerfile Jenkinsfile There are nothing in test directory, but both Jenkinsfile and Dockerfile are in test@script directory.
It seems that Jenkins only get the Jenkins from the repository. When it execute the Jenkinsfile, it can not build the docker image without Dockerfile.
How can I solve the problem?