dockerImage.getImageId() returns error groovy.lang.MissingMethodException: No signature of method: static

    stage ('Docker Image Build') {
        steps {
            script {
                dockerImage =
                def imageId = dockerImage.getImageId()
                sh "echo $imageId"

above is the pipeline script and below is the error message. please help me to resolve the issue

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: static org.jenkinsci.plugins.docker.workflow.Docker.getImageId() is applicable for argument types: () values:

Hi @saspath, and welcome to the Jenkins community!

Based on the docker variable documentation in my local Jenkins instance (available at https://jenkins-url/pipeline-syntax/globals#docker), I believe you need to be using def imageId = instead of trying to call a method getImageId(). A quick reading of the Docker Pipeline plugin source confirms that as well. Give that a try and let us know how it goes! is returning just the registry β€œ” ,
I wanted shaID so used below code.
imageID = sh(returnStdout: true, script: β€œdocker inspect -f β€˜{{.ID}}’ ${registry}”).trim()

Thank you for everything.

1 Like