SO far I tried following but with all I keep hitting ‘Jenkins’ doesn’t have 
label ‘docker’

Try 1 : Trying to override top-level agent. I get  ‘Jenkins’ doesn’t have 
label ‘docker’ and build hangs there

pipeline {

    agent { 

      docker {

            image 'maven:3-alpine' 

            args '-v /Users/npatel/.m2:/root/.m2' 

        }

    }

    stages {

        stage("Initialize") {

             agent { 

      docker {

            image 'maven:3.5.4-jdk-10' 

            args '-v /Users/npatel/.m2:/root/.m2' 

        }

    }

             steps{

                echo "buildId: ${env.BUILD_ID}"

             }

        }

    }


}


Try 2 : Trying to override any agent. I still get  ‘Jenkins’ doesn’t have 
label ‘docker’ and build hangs there

pipeline {

    agent any

    stages {

        stage("Initialize") {

             agent { 

      docker {

            image 'maven:3.5.4-jdk-10' 

            args '-v /Users/npatel/.m2:/root/.m2' 

        }

    }

             steps{

                echo "buildId: ${env.BUILD_ID}"

             }

        }

    }


}




On Thursday, September 27, 2018 at 1:01:25 PM UTC-7, nirav wrote:
>
> I am having trouble defining agents for my build pipeline. I need to use 2 
> docker images as agents for entire pipe. first 4 steps uses one image and 
> last two steps uses another one. I don't want to repeat agent statement in 
> every stage.
>
> It was easy with scripted pipe. I defined all my images on top level and 
> then for each stage I just need to say container("${name of the image}")
>      containers: [
>         containerTemplate(name: 'maven', image: 'maven:3.5.4-jdk-10', 
> ttyEnabled: true, command: 'cat'),
>         containerTemplate(name: 'docker', image: 'docker:18.03.1-ce', 
> ttyEnabled: true, command: 'cat'),
>     ]
>
>
> I see that declarative pipeline you can not define multiple agents at 
> pipeline level. 
>
> Is there a way I can define agent in one stage and in all other stages i 
> refer them by label/name etc? 
>
> ps - I don't want to do any setting under 'Manage Jenkins'.
>
> Thanks
>

-- 
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/5338401e-eb41-4c6a-818d-b3300dac3d14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to