I'm trying to build an image using the kubernetes pod in jenkins. The image that I'm using for pod is docker:latest and on it I'm trying to build and push in to my docker-repo. Docker-pipeline installed. When I try to do this, it gives me an error.
Commit message: "Update jenkinsPipeline"
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Building image)
[Pipeline] script
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker build -t testnginx/test1mynginx:latest .
/home/jenkins/agent/workspace/test-pipelines4@tmp/durable-6e84af99/script.sh: 1.
/home/jenkins/agent/workspace/test-pipelines4@tmp/durable-6e84af99/script.sh: docker: not
found
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Push image to registry)
Stage "Push image to registry" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
This is how my kubernetes cloud settings look like in Jenkins.enter image description here enter image description here enter image description here
The pipeline I'm using.
pipeline {
environment {
registry = "testnginx/test1mynginx"
registryCredential = 'dockerhub-creds'
dockerImage = ''
}
agent { label 'jenkins-slave' }
stages {
stage('Building image') {
steps{
script {
dockerImage = docker.build registry + ":latest"
}
}
}
stage('Push image to registry') {
steps{
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push()
}
}
}
}
}
}
If I try to go to the docker image and write dockev -v there, then there will already be a docker in it Docker version 19.03.12, build 48a66213fe. I think I’m missing something. Thanks for any help.