I don't really know the full extent of what you are trying to achieve, but
I wouldn't get down the road of writing a new kind of project 'just' for
this.

If it is about swapping some icons depending on an custom criteria, I'd
take a look at https://github.com/jenkinsci/greenballs-plugin and build
something similar (the interesting bits are in
https://github.com/jenkinsci/greenballs-plugin/blob/master/src/main/java/hudson/plugins/greenballs/GreenBallFilter.java
)

Vincent

2016-01-07 11:52 GMT+01:00 PaulD <[email protected]>:

> I'm trying to write my first plugin, so apologies for the probably very
> obvious questions.
>
> I'm trying to extend FreeStyleProject so that I can override the
> 'getIconColor' method with some custom functionality (currently just sets
> it
> to 'Not built' for testing but will be doing more later). My current code
> is
> as follows:
>
> package GitBranchFailureNotifier.GitBranchFailureNotifier;
> import hudson.Extension;
> import hudson.model.BallColor;
> import hudson.model.FreeStyleProject;
> import hudson.model.ItemGroup;
> import hudson.model.TopLevelItem;
> import hudson.model.TopLevelItemDescriptor;
>
> public class GitBranchFailureNotifierFreeStyleProject extends
> FreeStyleProject {
>
>
>
>         public GitBranchFailureNotifierFreeStyleProject(ItemGroup parent,
> String name) {
>                 super(parent, name);
>         }
>
>         @Override
>     public BallColor getIconColor() {
>         return BallColor.NOTBUILT;
>     }
>
>         @Extension
>         public static final class CustomJobDescriptor extends
> TopLevelItemDescriptor
>         {
>
>                 @Override
>                 public String getDisplayName() {
>                         return "Git Branch Failure Notifier";
>                 }
>
>                 @Override
>                 public TopLevelItem newInstance(ItemGroup arg0, String
> arg1)
> {
>                         return new
> GitBranchFailureNotifierFreeStyleProject(arg0, arg1);
>                 }
>
>         }
> }
>
> What I was expecting to happen was for this to show up as a new build type
> option alongside the existing set of builds, but clearly I'm doing
> something
> wrong.
>
> Also if there is a better way to override a method (ideally I'd like to do
> this for all jobs on our server) please let me know.
>
> Thanks.
>
>
>
> --
> View this message in context:
> http://jenkins-ci.361315.n4.nabble.com/Trying-to-extend-FreeStyleProject-to-override-a-method-tp4788542.html
> Sent from the Jenkins dev mailing list archive at Nabble.com.
>
> --
> 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/1452163972569-4788542.post%40n4.nabble.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAH-zGCjqWNVVfpzkk-5TKY1yfZ2qoMtZQ9-f0QxVCCCTQ2%3Doqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to