Are you talking about adding information Actions to the build records or
configuring actual build steps to run?
Both are quite easy to do but different. There are a couple of plugins that
does the latter already, the first ones that comes to mind is Configuration
Slicing [1] and Job DSL plugin [2].
Configuring a build step programmaticly would be something like
if (job.getPublishersList().get(FindBugsPublisher.class) == null) {
FindBugsPublisher findBugs = new FindBugsPublisher();
findBugs.setPattern("**/findbugs.xml");
job.getPublishersList().add(findBugs);
}
But not all plugins keep their api stable for external calls like this so
it might break if you upgrade findbugs beyond 4.63 for example, so you
might be safer in doing something like job dsl is doing and generate the
xml for the publisher config you're after, inserting it into the job's
config.xml and do a
job.doReload();
Although bugs are known to have manifested in some plugins that don't
handle reload from disk very well, at least I am known to not have handled
it well in mine ;) But the Job DSL plugin is a quite popular plugin (it
also does a reload iirc) so let's hope most of those bugs have been found
by now.
[1] https://wiki.jenkins-ci.org/display/JENKINS/Configuration+Slicing+Plugin
[2] https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin
/B
On Sat, Mar 19, 2016 at 6:23 PM, HarteJoe <[email protected]> wrote:
> Hi folks,
>
> I am a first time Jenkins developer with the intention of writing a new
> plugin. I have many builds (pipelines) that follow a very common format,
> and it has become cumbersome to perform the same configuration on them all.
> I'd like to write a plugin that can automatically add certain properties
> and post build steps to jobs of a certain kind. For example, ensure that
> JUnit, FindBugs and PMD are always enabled for these jobs.
> I'm not certain where to get started on how I can programatically add
> build actions to a job once I have a reference to the job item.
>
> Any pointers in the right direction would be very much appreciated.
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" 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-dev/10aea3fb-555f-4b0f-8b97-cec01724d2bb%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/10aea3fb-555f-4b0f-8b97-cec01724d2bb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Robert Sandell
*Software Engineer*
*CloudBees Inc.*
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" 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-dev/CALzHZS2ZZmDFGqxb8YvtZeU6bTW37yLt%3DVO025hQL%2BC2hdv6LQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.