Done after having looked 
at 
https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Syntax-Reference
 
:)

So, this now works:

pipeline {

    agent {
        dockerfile {
            label "docker"
        }
    }

    // ...
}

In order to restrict the data sent to the Docker daemon, I also declare a 
.dockerignore file which contains only:

*
!Dockerfile

This way, only the Dockerfile itself is sent to the build context for the 
image.

Best regards,
Damien.

On Wednesday, 15 February 2017 21:30:16 UTC+1, Damien Coraboeuf wrote:
>
> Hi,
>
> I'm starting to migrate some projects to the declarative pipeline model. 
> In particular, we want to build on an agent designated by the "docker" 
> label (which runs a Docker daemon) and then, I want to build inside a 
> Docker container described by my Dockerfile.
>
> Doing this:
>
> pipeline {
>    agent {
>      label "docker"
>      dockerfile true
>    }
> }
>
> This generates an error:
>
> Only one agent type is allowed per agent section
>
>
> Now, what should be the best approach to solve this, I think, common 
> pattern?
>
> I will try using agent+label, and then using docker+build+inside in steps, 
> but would not it more elegant to allow to use both a label and a Dockerfile 
> in the agent declaration?
>
> Thanks you for any feedback,
> Damien.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5d396eed-da85-46f5-a793-5d2fba5f880b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to