job_dsl plugin configure block problem

19 views
Skip to first unread message

Bill K

unread,
Jun 4, 2013, 7:16:44 PM6/4/13
to jenkins...@googlegroups.com
Hello, 

I am using job_dsl plugin to create jobs in a loop. We have several 'sets' of code all of which will need an identical set of jobs. This is working fine for things using the built in helpers but we also have a need to use some plugins not directly supported. I have created configure blocks which enable the plugins but variable substitution is not working within the configure blocks. The last value of the loop is used in all cases. Ex; 

def FeatureSets = ['DSL1','DSL2'] 

for (i in FeatureSets) 

   y=FeatureSets.indexOf(i) 
   println "y=$y" 
   job { 
      name "DSL_TEST_${i}" 

      configure { project -> 
         SideBarLinksNode = project/'properties'/'hudson.plugins.sidebar__link.ProjectLinks' 
         SideBarLinksNode/links/'hudson.plugins.sidebar__link.LinkAction'/url << "${i}/index.html" 
         SideBarLinksNode/links/'hudson.plugins.sidebar__link.LinkAction'/text << "${i} Doxygen HTML" 
         SideBarLinksNode/links/'hudson.plugins.sidebar__link.LinkAction'/icon << "document.gif" 
      } 
   } 


This generates two jobs named DSL_TEST_DSL1 and DSL_TEST_DSL2 as intended. It also adds the sidebar links plugin but the content of the links is the same in both jobs and is DSL2 twice instead of DSL1 in job 1 and DSL2 in job 2. 

Any help would be greatly appreciated! 

Thanks

Pete Akey

unread,
Jun 4, 2013, 9:55:39 PM6/4/13
to jenkins...@googlegroups.com
Can you clarify this point:  "This generates two jobs named DSL_TEST_DSL1 and DSL_TEST_DSL2 as intended. It also adds the sidebar links plugin but the content of the links is the same in both jobs and is DSL2 twice instead of DSL1 in job 1 and DSL2 in job 2."

The way it reads to me, and correct me if I have misinterpreted, is as follows.

Two jobs, named: 
DSL_TEST_DSL1
DSL_TEST_DSL2

Two links on the sidebar links plugin (I'm not familiar with this plugin), with the following text:
DSL_TEST_DSL1
DSL_TEST_DSL2.

The "content" is the same.  Does this mean the link takes you to the same URL?  For example, http://jenkins.local/jobs/<job_name>/3, or whatever your build number is.


I don't think I'm processing that correctly.

Pete
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bill Koester

unread,
Jun 4, 2013, 11:19:11 PM6/4/13
to jenkins...@googlegroups.com
Two jobs, named: 
DSL_TEST_DSL1
DSL_TEST_DSL2

Two links on the sidebar links plugin (I'm not familiar with this plugin), with the following text:
DSL_TEST_DSL2
DSL_TEST_DSL2.

In both jobs the variable ${i} inside the configure block gets expanded to the last value, DSL2..Outside of the configure block ${i} expands as DSL1 in job 1 and DSL2 is job two as it should


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/rukrVecaxE4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

Jan Nikolai Trzeszkowski

unread,
Nov 21, 2014, 3:40:57 AM11/21/14
to jenkins...@googlegroups.com
I just ran into the same issue and managed to solve this by following the steps describe here in the section Reusable Configure Blocks (just at the very end of the page).
Extracting this to a Closure ensures that the parameters get evaluated immediately.
Reply all
Reply to author
Forward
0 new messages