[JIRA] (JENKINS-38173) docker.build() should be to work without an image name

2 views
Skip to first unread message

docwhat@gerf.org (JIRA)

unread,
Sep 13, 2016, 2:30:01 PM9/13/16
to jenkinsc...@googlegroups.com
Christian Höltje created an issue
 
Jenkins / Improvement JENKINS-38173
docker.build() should be to work without an image name
Issue Type: Improvement Improvement
Assignee: Jesse Glick
Components: docker-workflow-plugin
Created: 2016/Sep/13 6:29 PM
Environment: Jenkins 2.7.3
docker-commons v1.4.1 Docker Commons Plugin
docker-workflow v1.8 CloudBees Docker Pipeline
Priority: Minor Minor
Reporter: Christian Höltje

When building a docker image that won't be pushed (e.g. for a build environment) then I would
expect I could do def image = docker.build() and then use the image to build things.

I don't need an image to be tagged, and in fact it would be preferable for it not to tagged since I may have collisions otherwise. e.g. docker.build("foo") run by two concurrent jobs would, I assume, cause havoc.

The work around is to assign something like {{docker.build("somename:$

{BUILD_NUMBER}

")}} but I don't even like that since the code could be forked and run in parallel... or the Jenkinsfile could be copy-and-pasted.

And I can't use $BUILD_TAG because my jobs have / characters in it. I could normalize them, but now I'm building infrastructure into my Jenkinsfile to support something I don't want/need.

The traceback I get when using docker.build() is:

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.jenkinsci.plugins.docker.workflow.Docker build)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:181)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:117)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
	at WorkflowScript.getRubyImage(WorkflowScript:88)
	at WorkflowScript.run(WorkflowScript:20)
	at ___cps.transform___(Native Method)
	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:48)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:77)
	at sun.reflect.GeneratedMethodAccessor393.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Feb 13, 2017, 3:08:02 PM2/13/17
to jenkinsc...@googlegroups.com
Jesse Glick commented on Improvement JENKINS-38173
 
Re: docker.build() should be to work without an image name

Probably needs a broader rewrite, as in JENKINS-34276. The entire way image names and registry prefixes are used in this plugin seems to have been a design mistake. Not sure how to change it compatibly now.

Better to just run sh 'docker build .' yourself and parse out the resulting ID.

Reply all
Reply to author
Forward
0 new messages