I create agent as string parameters and put in the jennkinsfile without 
quote.

agent {
node {
label params.agent
}
}

Pada Rabu, 03 Mei 2017 21.58.09 UTC+7, ishan jain menulis:
>
> I am using declarative syntax to build my pipeline. I am loading several 
> variables from a properties file in the beginning and i now i would like to 
> control the 'on which slave node something executes' via variables. But i 
> cannot figure out how to use variable as a agent label. The following is 
> one of the snippets and like all its other variations, it fails:
>
> properties = null
>
> def loadProperties() {
>  node {
>          checkout scm
>            properties = readProperties file: 'pipeline.properties'
>         echo "Immediate one ${properties.repo}"
> }
> }
>
> pipeline {
>    agent none
>  
>      stages {
>        
>                stage ('prepare') {
>                     agent any
>                       
>                         steps {
>                         script {
>                                        loadProperties()
>                                }
>                       }
>               }
>               stage('Build') {
>            
>                    agent { label '${properties.agent}' }
>                   
>                         steps {
>                         sh 'hostname'
>                           echo properties.repo
>                    }
>                       
>         }
>    }
> }
>
>
>

-- 
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/2c5e2b62-11d7-4147-a3bf-532833dd03c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to