can i use variable to specify the agent label in my declarative pipeline ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

can i use variable to specify the agent label in my declarative pipeline ?

ishan jain
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

Eric Pyle-3
It should work if you use double quotes around your agent variable. Variable resolution will not happen within single quotes.

On 5/3/2017 10:58 AM, ishan jain wrote:
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
[hidden email]
http://www.siemens.com/plm

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3dff065d-8b81-78fc-8ce5-ccd98b533ee9%40cd-adapco.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

ishan jain
Hi Eric,

I tried putting the var in double quotes but still it is not able to resolve it. I get 'There are no nodes with the label ‘null’' error. I am able to print the value of exact same variable but it seems it is not resolving the variable name in here. Is there something else i need to do here ?


On Wednesday, 3 May 2017 17:51:21 UTC+2, Eric Pyle wrote:
It should work if you use double quotes around your agent variable. Variable resolution will not happen within single quotes.

On 5/3/2017 10:58 AM, ishan jain wrote:
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="aMrXnwFLAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="aMrXnwFLAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">eric...@...
<a href="http://www.siemens.com/plm" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;">http://www.siemens.com/plm

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

Eric Pyle-3
OK, so the variable is now being evaluated, but it is not set. Possibly a variable scoping issue? Can you post the exact code?

On 5/4/2017 4:23 AM, ishan jain wrote:
Hi Eric,

I tried putting the var in double quotes but still it is not able to resolve it. I get 'There are no nodes with the label ‘null’' error. I am able to print the value of exact same variable but it seems it is not resolving the variable name in here. Is there something else i need to do here ?

On Wednesday, 3 May 2017 17:51:21 UTC+2, Eric Pyle wrote:
It should work if you use double quotes around your agent variable. Variable resolution will not happen within single quotes.

On 5/3/2017 10:58 AM, ishan jain wrote:
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="aMrXnwFLAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" moz-do-not-send="true">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" onclick="this.href='https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" moz-do-not-send="true">https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;" moz-do-not-send="true">https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="aMrXnwFLAAAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;" moz-do-not-send="true">eric...@...
<a href="http://www.siemens.com/plm" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g';return true;" moz-do-not-send="true">http://www.siemens.com/plm
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
[hidden email]
http://www.siemens.com/plm

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/856f7178-0d3c-5163-0cce-84e055bd493e%40cd-adapco.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

ishan jain
Hi Eric,

This the full code that copied earlier. You would only require to create a properties file. The other echo statements that i have put are printing out the values just fine. 

On Thursday, 4 May 2017 22:47:14 UTC+2, Eric Pyle wrote:
OK, so the variable is now being evaluated, but it is not set. Possibly a variable scoping issue? Can you post the exact code?

On 5/4/2017 4:23 AM, ishan jain wrote:
Hi Eric,

I tried putting the var in double quotes but still it is not able to resolve it. I get 'There are no nodes with the label ‘null’' error. I am able to print the value of exact same variable but it seems it is not resolving the variable name in here. Is there something else i need to do here ?

On Wednesday, 3 May 2017 17:51:21 UTC+2, Eric Pyle wrote:
It should work if you use double quotes around your agent variable. Variable resolution will not happen within single quotes.

On 5/3/2017 10:58 AM, ishan jain wrote:
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
[hidden email]
<a href="http://www.siemens.com/plm" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;">http://www.siemens.com/plm
--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="T_Qiw7upAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="T_Qiw7upAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">eric...@...
<a href="http://www.siemens.com/plm" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;">http://www.siemens.com/plm

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3a1840ac-a74a-4231-ab3d-ed573f6243bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

chris scott
Hi did you guys every get to a resolution on this? I have exactly the same issue. 


On Friday, 5 May 2017 12:10:51 UTC+1, ishan jain wrote:
Hi Eric,

This the full code that copied earlier. You would only require to create a properties file. The other echo statements that i have put are printing out the values just fine. 

On Thursday, 4 May 2017 22:47:14 UTC+2, Eric Pyle wrote:
OK, so the variable is now being evaluated, but it is not set. Possibly a variable scoping issue? Can you post the exact code?

On 5/4/2017 4:23 AM, ishan jain wrote:
Hi Eric,

I tried putting the var in double quotes but still it is not able to resolve it. I get 'There are no nodes with the label ‘null’' error. I am able to print the value of exact same variable but it seems it is not resolving the variable name in here. Is there something else i need to do here ?

On Wednesday, 3 May 2017 17:51:21 UTC+2, Eric Pyle wrote:
It should work if you use double quotes around your agent variable. Variable resolution will not happen within single quotes.

On 5/3/2017 10:58 AM, ishan jain wrote:
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/4cfff4fb-aa1f-4ad2-9017-d6dcf89a7b36%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
[hidden email]
<a href="http://www.siemens.com/plm" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;">http://www.siemens.com/plm
--
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-use...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/d96a65f5-9926-4325-9f02-1c4649330b06%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
[hidden email]
<a href="http://www.siemens.com/plm" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.siemens.com%2Fplm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNECCBXoLbCcwYh0_VxSnlYJmjCj7g&#39;;return true;">http://www.siemens.com/plm

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f61f808b-183c-4016-a8b7-416feca3e839%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

gilad-2
In reply to this post by ishan jain
same here :-\

even created a StackOverflow issue for this:
https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically

On Wednesday, May 3, 2017 at 5:58:09 PM UTC+3, ishan jain wrote:
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4e4b367c-76c3-49b9-96bf-f0512dfaae73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

gilad-2
In reply to this post by ishan jain

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/17136fe1-f194-413a-b3be-ce51354bfb09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

Björn Rohlén


On Tuesday, 10 October 2017 16:58:44 UTC+2, [hidden email] wrote:
same here :-\

even created a StackOverflow issue for this:
<a href="https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F46630168%2Fin-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFp71qICkEI3f--VN2FDGkWGKIFZA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F46630168%2Fin-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFp71qICkEI3f--VN2FDGkWGKIFZA&#39;;return true;">https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically

There is an perfectly good answer in this issue?  

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/48d73dc1-66d9-4046-a6d8-5420511082e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

gilad-2
not as far as I know... still an open issue

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fd780a61-bd9c-49b5-8df6-584abe2da48b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

Robert Hales
In reply to this post by gilad-2
I posted a reply to this. It was a head twister, but I think I solved the problem and learned some interesting things. 

On Tuesday, October 10, 2017 at 8:58:44 AM UTC-6, [hidden email] wrote:
same here :-\

even created a StackOverflow issue for this:
<a href="https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F46630168%2Fin-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFp71qICkEI3f--VN2FDGkWGKIFZA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F46630168%2Fin-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFp71qICkEI3f--VN2FDGkWGKIFZA&#39;;return true;">https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f5caa2f6-aebe-4e79-9993-5c515d39889c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

ishan jain
Hi Robert,

How did you resolve it ? I could never get it working with anything.

On Wednesday, 11 October 2017 23:01:19 UTC+2, Robert Hales wrote:
I posted a reply to this. It was a head twister, but I think I solved the problem and learned some interesting things. 

On Tuesday, October 10, 2017 at 8:58:44 AM UTC-6, [hidden email] wrote:
same here :-\

even created a StackOverflow issue for this:
<a href="https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F46630168%2Fin-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFp71qICkEI3f--VN2FDGkWGKIFZA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F46630168%2Fin-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFp71qICkEI3f--VN2FDGkWGKIFZA&#39;;return true;">https://stackoverflow.com/questions/46630168/in-a-declarative-jenkins-pipeline-can-i-set-the-agent-label-dynamically

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a4b297df-d301-4838-b89a-7469bfa612ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can i use variable to specify the agent label in my declarative pipeline ?

dandeliondodgeball

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/37a716b8-9574-4f21-b18f-0678016f301e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.