1
votes

I am new to jenkins, and I am trying to basically build an image from a Dockerfile and get a green light after the image is build.

I keep running into the issue:

[nch-gettings-started_master-SHLPWPHFAAYXF7TNKZMDMDGWQ3SU5XIHKYETXMIETUSVZMON4MRA] Running shell script

  • docker build -t my-image:latest .

/Users/Shared/Jenkins/Home/workspace/nch-gettings-started_master-SHLPWPHFAAYXF7TNKZMDMDGWQ3SU5XIHKYETXMIETUSVZMON4MRA@tmp/durable-a1f989d1/script.sh: line 2: docker: command not found

script returned exit code 127

My pipeline as code is as follow:

node {
  stage('Clone repository') {
    checkout scm
  }

  stage('Build image') {
    def app = docker.build("my-image:my-tag")
  }
}

I have also tried:

pipeline {
  agent any


  stages {
    stage ('clonse repo') {
      steps {
        checkout scm
      }
    }

    stage('build image') {
      steps {
        docker.build("my-image:my-tag")
      }
    }
  }
}

I have already installed the docker pipeline plugin. and by the way jenkins is running in my localhost enter image description here

1

1 Answers

0
votes
line 2: docker: command not found

That is your issue. Depending on where the job is running, you need to make sure your slave image/VM/machine has docker installed.

If you have jobs running on your master, make sure docker is installed there. If you have jobs running in Kubernetes, make sure your slave image has docker installed.

EDIT :

Just saw that you're running on localhost. Make sure you have docker installed there and its in your $PATH