I am trying to use docker agent in Jenkinsfile:
pipeline {
agent {
docker {
image "openjdk:jdk-alpine"
}
}
stages {
stage("Hello") {
steps {
sh "echo 'Hello'"
}
}
}
}
But I have got:
/var/jenkins_home/workspace/tesler@tmp/durable-7aaf5de1/script.sh: 1: /var/jenkins_home/workspace/tesler@tmp/durable-7aaf5de1/script.sh: docker: not found
[Pipeline] isUnix
[Pipeline] sh
+ docker pull openjdk:jdk-alpine
/var/jenkins_home/workspace/tesler@tmp/durable-af6a5d64/script.sh: 1: /var/jenkins_home/workspace/tesler@tmp/durable-af6a5d64/script.sh: docker: not found
I am testing this with Jenkins casc. I need docker so I have copy its definition to casc file from https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos/docker
It is not working. In jenkins dockers lists there is an error:
I hope that when I will fix docker error Jenkinsfile will work too. What is wrong?