staging with specific agent settings strange behavior

63 views
Skip to first unread message

Dan Tran

unread,
Oct 20, 2017, 6:43:17 PM10/20/17
to Jenkins Users

Hi

I have a multi-stage pipeline using a global docker agent, except at one stage where I need to use  none docker agent ( ie a just a pure linux host)

and run to this error and look like my stage still inside docker from the previous stage.  is it a bug?

[Bitbucket] Notifying commit build result
[Pipeline] withEnv
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: 
[withMaven] use JDK installation provided by the build agent
WARNING: Specified Maven 'M3' cannot be installed, will be ignored.Step running within docker.image() tool installations are not available see https://issues.jenkins-ci.org/browse/JENKINS-36159. 
$ docker exec ff8d1de358d03e06f316c42208c6dd49fb02d41214f59e18a744e21e911e9353 env printenv MAVEN_HOME
$ docker exec ff8d1de358d03e06f316c42208c6dd49fb02d41214f59e18a744e21e911e9353 env printenv M2_HOME
$ docker exec ff8d1de358d03e06f316c42208c6dd49fb02d41214f59e18a744e21e911e9353 env /bin/sh -c "which mvn"
[withMaven] with executable null

Thanks

-Dan

Dan Tran

unread,
Oct 24, 2017, 4:38:35 AM10/24/17
to Jenkins Users
here is my sample pipeline script

pipeline {


    agent {
        docker {
            image "comp/xxxx:yyyy"
        }
    }
    
    tools {
        jdk 'JAVA8'
    }    
    
    
    
    stages {

        stage("hello") {
            agent {
                label 'vjd05'
            }            
            steps {
               withMaven( maven: 'M3', globalMavenSettingsConfig: 'maven-global', mavenSettingsConfig: 'maven-user', mavenLocalRepo: '.repository' ) {
                    sh "mvn -v"

Robert Hales

unread,
Oct 24, 2017, 10:43:02 AM10/24/17
to Jenkins Users
If you specify an agent for the entire pipeline, everything in that pipeline will run in that agent. You need to specify 'agent none' on the pipeline, then specify an agent on each individual stage. 

Dan Tran

unread,
Oct 24, 2017, 12:20:17 PM10/24/17
to Jenkins Users

Thanks for confirming it is not a bug,  however, this behavior is very odd where if  I have 99 stages using same docker agent, and one on a different agent,  I need to repeat 99 times for each stage's agent settings

is this behavior officially documented? if not may need a doc bug 

Thanks

-Dan

Btw, we have another pipeline with global agent is a Linux host agent, and one stage on window without issue 

Robert Hales

unread,
Oct 24, 2017, 12:59:54 PM10/24/17
to Jenkins Users
I actually may have spoke incorrectly... 

When you specify an agent on the pipeline, you can't later use "agent none" on a stage and expect that stage to go back to the flyweight agent on the master (at least, that's what my tests reveal). But I am not sure I have ever tried farming out from node A (specified at the pipeline level) to node B (specified at the stage level). 

Dan Tran

unread,
Oct 24, 2017, 7:08:07 PM10/24/17
to Jenkins Users

I would like to hear from Jenkins folks to confirm if this is correct behavior :-)

Thanks

-Dan

Dan Tran

unread,
Oct 25, 2017, 2:35:02 PM10/25/17
to Jenkins Users
Reply all
Reply to author
Forward
0 new messages