Reputation: 770
When using a jenkins pod provisioned by openshift.
Using a Jenkins file like below
node {
def app
stage('Clone repository') {
checkout scm
}
stage('Build image') {
app = docker.build("showcase")
}
stage('Test image') {
app.inside {
sh 'echo "Tests passed"'
}
}
stage('Push image') {
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
app.push("${env.BUILD_NUMBER}")
app.push("latest")
}
}
}
Upon running a build I see the following
docker build -t showcase .
/var/lib/jenkins/jobs/showcase-2/workspace@tmp/durable-018470ac/script.sh: line 2: docker: command not found
It appears that docker is not available on the jenkins image:
openshift/jenkins:2
Could some-one help me understand what I can do to make docker available?
Upvotes: 1
Views: 1568
Reputation: 2683
You need to install docker to your Jenkins. You can find a how-to over here. With the following Dockerfile code you can create your own Jenkins with Docker installed:
FROM jenkins/jenkins
USER root
RUN apt update && apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
RUN apt update && apt install -y docker-ce
RUN usermod -aG docker jenkins
USER jenkins
This won't work out of the box for openshift/jenkins, since it is based on RedHat, you will need to replace those apt
commands. You might be able to find some hints on that here.
Upvotes: 1