I've got a PR up for this now -
https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/107

A.

On Sun, Feb 5, 2017 at 9:01 PM, Staffan Forsell <sta...@gmail.com> wrote:

> Hmmm, of course I found https://issues.jenkins-ci.org/browse/JENKINS-41668
> a couple of minutes later...
>
> On Sunday, 5 February 2017 20:50:16 UTC+1, Staffan Forsell wrote:
>>
>> I have an normal pipeline that looks like this:
>>
>> #!groovy
>> node('docker_host') {
>>   stage("checkout") {
>>     p4sync credential: 'superSecretCred', depotPath: '//path'
>>   }
>>   def myEnv
>>   stage("docker build") {
>>     myEnv = docker.build("mytag", "utils/docker")
>>   }
>>   myEnv.inside {
>>     stage("build") {
>>       sh "./gradle"
>>     }
>>     }
>> }
>>
>> It builds a docker image and run the build stage in this image. The only
>> non-standard stuff is that the Dockerfile is not in the root but in the
>> "utils/docker" subdir to reduce the build context for docker.
>> I'm trying to convert this to a declarative pipeline but I can't find a
>> way to get it to accept the Dockerfile in a separate dir. Normally this is
>> done by adding the "utils/build" at the end of the docker build command.
>> My converted attempt looks like this:
>>
>> pipeline {
>>   agent {
>>     label "docker_host"
>>   }
>>   stages {
>>     stage("Checkout") {
>>       steps {
>>         p4sync credential: 'superSecretCred', depotPath: '//path'
>>       }
>>     }
>>     stage("Echo world") {
>>       agent {
>>         dockerfile {
>>           label "docker_host"
>>           args "utils/docker"
>>           // dockerfile "utils/docker/Dockerfile"
>>         }
>>       }
>>       steps {
>>         sh "./gradle"
>>       }
>>     }
>>   }
>> }
>>
>> This fails with
>> java.io.IOException: java.io.FileNotFoundException:
>> /jenkins/workspace/test-job-declarative@2/Dockerfile (No such file or
>> directory)
>> at hudson.remoting.FastPipedInputStream.read(FastPipedInputStre
>> am.java:169)
>> at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
>> at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
>> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
>> at java.io.InputStreamReader.read(InputStreamReader.java:184)
>> at java.io.Reader.read(Reader.java:140)
>> at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2001)
>> at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1980)
>> at org.apache.commons.io.IOUtils.copy(IOUtils.java:1957)
>> at org.apache.commons.io.IOUtils.copy(IOUtils.java:1907)
>> at org.apache.commons.io.IOUtils.toString(IOUtils.java:778)
>> at org.apache.commons.io.IOUtils.toString(IOUtils.java:803)
>> at org.jenkinsci.plugins.workflow.steps.ReadFileStep$Execution.
>> run(ReadFileStep.java:89)
>> at org.jenkinsci.plugins.workflow.steps.ReadFileStep$Execution.
>> run(ReadFileStep.java:81)
>> at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonB
>> lockingStepExecution$1$1.call(AbstractSynchronousNonBlocking
>> StepExecution.java:47)
>> at hudson.security.ACL.impersonate(ACL.java:221)
>> at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonB
>> lockingStepExecution$1.run(AbstractSynchronousNonBlockingSte
>> pExecution.java:44)
>> at java.util.concurrent.Executors$RunnableAdapter.call(
>> Executors.java:471)
>> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1145)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:615)
>> at java.lang.Thread.run(Thread.java:745)
>> Caused by: java.io.FileNotFoundException: /jenkins/workspace/test-job-de
>> clarative@2/Dockerfile (No such file or directory)
>> at java.io.FileInputStream.open0(Native Method)
>> at java.io.FileInputStream.open(FileInputStream.java:195)
>> at java.io.FileInputStream.<init>(FileInputStream.java:138)
>> at hudson.FilePath$33.invoke(FilePath.java:1789)
>> at hudson.FilePath$33.invoke(FilePath.java:1782)
>> at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
>> at hudson.remoting.UserRequest.perform(UserRequest.java:153)
>> at hudson.remoting.UserRequest.perform(UserRequest.java:50)
>> at hudson.remoting.Request$2.run(Request.java:332)
>> at hudson.remoting.InterceptingExecutorService$1.call(Intercept
>> ingExecutorService.java:68)
>> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1142)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:617)
>> ... 1 more
>>
>> Using the dockerfile closure, it's unclear if args is for the build
>> command or the subsequent run command (my guess is the latter).
>> Anybody know a way to use a Dockerfile that's not in the root? Or is it
>> not supported (yet)?
>>
>> /Thanks Staffan
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/78dea921-bc15-4e4f-8662-209f4aa80e86%40googlegroups.
> com
> <https://groups.google.com/d/msgid/jenkinsci-users/78dea921-bc15-4e4f-8662-209f4aa80e86%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAPbPdOZL0bWU%3DnkdN2BLyAqtPSbCcHDh_8kQTR7Wkzq2vy8UPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to