Which plugin is required to have docker.build work in Jenkins?

Viewed 1385

I am using docker on Mac and have Jenkins running in docker container.

Client is interacting with docker daemon on host machine.

I have following plugins installed:

  • docker-plugin
  • workflow-aggregator

I do have docker client / command working in container. I have also checked it using sh and even docker cloud can spin up agents.

But below Jenkinsfile is contantly throwing error.

def image

pipeline {
    agent {
        label "container"
    }
    stages {
        stage('Build') {
            steps {
                script {
                    image = docker.build("username/image:$BUILD")
                }
            }
        }
    }
}

But I am constantly facing below error message:

groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding
2 Answers

Error: No such property: docker for class: groovy.lang.Binding

No such Docker property indicates that Docker Pipeline plugin is not installed.

It's little confusing because name of these three plugins are very much similar to each other's id:

If you have this issue:

groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding.

We most likely encountered the same issue, in order to fix it I only had to install the Docker Pipeline plugin in Jenkins, so all you have to do is go to:

Jenkins Homepage > Manage Jenkins > Manage Plugins > Available

Search for Docker Pipeline install it restart jenkins and you are ready to go.

For more info about Docker Pipeline Plugin Scripts click here.

Related