Thanks James.
I am trying out the CloudBees template approach using Groovy template
transformations.
Overall, it seems nice; however, it is not clear how to access attributes in
Groovy code. The CloudBees doc shows this trivial example of adding Groovy code:
<foo>
<%
for (int i=0; i<100; i++) {
if ((i%2)==0) {
%>
<data>${i}</data>
<%
}
}
%>
</foo>
I’d like to use an attribute whose value is provided by the user when the job
is instantiated. Here is a simplified example of what I am trying to do:
<foo>
<%
def x = “a” + $someAttribute
%>
<data>${x}</data>
</foo>
Unfortunately, the above example does not work. Does anyone know if it is
possible to access attribute values in the Groovy template code?
Thanks in advance.
Bob
From: teilo [mailto:[email protected]]
Sent: Tuesday, May 21, 2013 9:11 AM
To: [email protected]
Cc: 'teilo'; Bob Bick
Subject: Re: Mass Jenkins job updates
You can add new parameters, so long as you handle the fact that the parameter
may be null in the transformer used by the template.
There's a bit about this in my presentation from the Jenkins User event in
London, and the online docs from cloudbees should give you more details of this.
Others have pointed out there may be other ways to solve the same issue with
various advantages/disadvantages.
On Tuesday, 21 May 2013 14:04:55 UTC+1, Bob Bick wrote:
Thanks James, that clears it up!
I guess a template could not add a new parameter. Is that correct? Or, maybe
there is a way to define a default value that all jobs would get?
Bob
From: teilo [mailto:[email protected]<javascript:>]
Sent: Tuesday, May 21, 2013 8:59 AM
To: [email protected]<javascript:>
Cc: Bob Bick
Subject: Re: Mass Jenkins job updates
Hi Bob,
"Just so I understand what you are saying... If you create a job based on a
template, and then you make a change to the template, all jobs are
automatically updated based on the template?"
Yes - if your jobs are based on that template then they are all automatically
updated.
"I have not tried this; however, I would assume that you'd need to modify
the template and then re-run the transformation with the exact same parameters
to re-create each job. "
That's not how the plugin works - when you create a job you no longer create a
"FreeStyle" job or a "Maven2" job, you create a "Mytemplate" job. The only
thing the job will ask you for is the parameters defeined by the template, and
these are stored in the job. The template then converts these parameters using
the definition stored in the template.
"If so, that seems like a hassle because you'd need to re-run the
transformation for many jobs which would be inefficient. "
That would be ineficient - which is why it doesn;t work like that.
Basically, if your job has been created from a template then once you update
the template then the job is automatically updated.
However your jobs are not created from a tempalte, so you would first have to
create a template and then convert (recreate?) your jobs to be based on the
template.
/James
On Tuesday, 21 May 2013 13:52:19 UTC+1, Bob Bick wrote:
Thank you for the response.
Just so I understand what you are saying... If you create a job based on a
template, and then you make a change to the template, all jobs are
automatically updated based on the template? I have not tried this; however, I
would assume that you'd need to modify the template and then re-run the
transformation with the exact same parameters to re-create each job. If so,
that seems like a hassle because you'd need to re-run the transformation for
many jobs which would be inefficient.
Do I understand that correctly?
Thanks,
Bob
-----Original Message-----
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of teilo
Sent: Tuesday, May 21, 2013 4:03 AM
To: [email protected]<mailto:[email protected]>
Subject: Mass Jenkins job updates
I use option 4 - Jenkins enterprise
This won't be a drop in solution for you as your jobs need to be templatized
before you can update them by just tweaking the template. You could do this
with some groovy but that has drawbacks if you mess up your groovy.
But Jenkins enterprise has other benefits (at least to me) that the initial
pain of moving jobs too templates was worth it.
Configuration slicing didn't do it to me, groovy can be an issue if you only
have a subset of your jobs share the same config - as you have to maintain a
whitelist/blacklist.
The other option is wget and some sed/perl/... scripting
--
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]<mailto:[email protected]>.
For more options, visit https://groups.google.com/groups/opt_out.
*** *** ***
This message contains information which may be confidential and privileged.
Unless you are the addressee (or authorized to receive for the addressee), you
may not use, copy or disclose to anyone the message or any information
contained in the message. If you have received the message in error, please
advise the sender by reply e-mail and delete the message.
*** *** ***
This message contains information which may be confidential and privileged.
Unless you are the addressee (or authorized to receive for the addressee), you
may not use, copy or disclose to anyone the message or any information
contained in the message. If you have received the message in error, please
advise the sender by reply e-mail and delete the message.
*** *** ***
This message contains information which may be confidential and privileged.
Unless you are the addressee (or authorized to receive for the addressee), you
may not use, copy or disclose to anyone the message or any information
contained in the message. If you have received the message in error, please
advise the sender by reply e-mail and delete the message.
--
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].
For more options, visit https://groups.google.com/groups/opt_out.