I'm trying to run Dockerfile in Jenkinsfile pipeline. I have the following Dockerfile:
FROM ubuntu:latest
ENV VERSION=1.2.0
RUN apt-get update -y
RUN apt-get install -y python vim zip unzip
RUN mkdir -p /tmp
WORKDIR /tmp
COPY zip_job.py ./
RUN cat /etc/lsb-release
RUN uname -m
RUN ls -l /tmp
This is my Jenkinsfile:
pipeline {
agent { dockerfile true }
stages {
stage('Build') {
steps {
sh 'python zip_job.py'
}
}
stage('Publish') {
steps {
rtServer (
id: 'Artifactory-1',
url: 'https://aidock.jfrog.io/artifactory/devops-assignment/',
username: 'super-user'
password: 'Qw12856!'
)
rtUpload (
serverId: 'Artifactory-1',
spec: '''{
"files": [
{
"pattern": "tmp/*.zip",
"target": "binary-storage/1.2.0
}
]
}''',
)
}
}
stage('Report') {
steps {
echo 'Hello World'
}
}
stage('Cleanup') {
steps {
echo 'Hello World'
}
}
}
}
My working directory in Docker should be /tmp. When running a build I get the following error:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/My-Pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Agent Setup)
[Pipeline] isUnix
[Pipeline] readFile
[Pipeline] sh
+ docker build -t b96873ea12524b982ef8ce77660ade7f3744e812 -f Dockerfile .
/var/jenkins_home/workspace/My-Pipeline@tmp/durable-f53af459/script.sh: 1: /var/jenkins_home/workspace/My-Pipeline@tmp/durable-f53af459/script.sh: docker: not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
Tried almost every trick in the book but yet it is not working. Docker Plugins are installed.
Appreciate the help. Thanks!