Jenkins docker pipeline error
Solution 1
The issue was I needed to install the Docker Pipeline plugin in Jenkins.
Solution 2
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.
Solution 3
Maybe I'm missing some part of your code, but where do you define the docker? If that's the complete Groovy script, you're trying to bind a variable which isn't declared anything, so it's not to weird that it fails, right?
Just define a docker it that's what you want, like:
def docker = "my docker" // something similar like this
And it will at-least resolve your missing property exception.
Whenever we see the error like below :
groovy.lang.MissingPropertyException: No such property:
It means , groovey script did not able to find the property mentioned post the colon sign : , so we need to either define the user defined variable/property or use the correct one from API.
Solution 4
As Pete says you will have to install the Docker Pipeline plugin. You can do that though the Jenkins UI.
Pete
Interested in Java, Jenkins, AWS, docker and IBM WebSphere Application Server/MQ.
Updated on August 03, 2022Comments
-
Pete over 1 year
I'm trying to follow this tutorial to create a simple docker environment in as part of my jenkins pipeline build.
I'm trying to build a couple of docker images just as a test before I do my maven build. At the moment I have the following groovy for my Jenkinsfile:
#!groovy node { stage 'Building docker env' def dbImage = docker.build('oracle', 'docker/oracle') def wlpImage = docker.build('liberty', 'docker/liberty') stage 'Running maven build' git url: 'https://mysite/myproject.git', branch: 'docker' def mvnHome = tool 'maven 3.3.9' sh "${mvnHome}/bin/mvn -B clean install" }
I'm trying to have the docker build look in the directory "docker/oracle" and call the Dockerfile in that directory, and build the docker image named 'oracle', and same for liberty. At the moment though it's giving me this error:
Running on master in /root/.jenkins/workspace/pipeline_test [Pipeline] { [Pipeline] stage (Building docker env) Using the ‘stage’ step without a block argument is deprecated Entering stage Building docker env Proceeding [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) ...
Any ideas what could be the problem with the docker.build command I'm using? (or could it be something I forgot to install in Jenkins?)