Reputation: 1035
Why is it that docker not found when i use docker as an agent in jenkins pipeline?
+ docker inspect -f . node:7-alpine
/var/jenkins_home/workspace/poobao-aws-services@tmp/durable-
13f890b0/script.sh: 2: /var/jenkins_home/workspace/project-
name@tmp/durable-13f890b0/script.sh: docker: not found
In Global Tools Configuration, I have docker as automatically install.
Upvotes: 0
Views: 1033
Reputation: 5027
I have docker set to install automatically as follows, with a declarative pipeline as follows...
My jenkinsfile then has this initialization stage (amended from here)
stage('Install dependencies') {
steps {
script {
def dockerTool = tool name: 'docker', type: 'org.jenkinsci.plugins.docker.commons.tools.DockerTool'
withEnv(["DOCKER=${dockerTool}/bin"]) {
//stages
//here we can trigger: sh "sudo ${DOCKER}/docker ..."
}
}
}
}
When built it then installs automatically...
Upvotes: 1