Server Listener - Adding a build trigger programmatically

Hi,

I have a plugin that implements BuildServerListener and performs the task of automatically adding a build trigger whenever a new build configuration is created by implementing buildTypeRegistered() method. The trigger is added using  SBuildType.addBuildTrigger() method by supplying a custom BuildTriggerDescriptor. Everything works fine here and i can see the newly added trigger from the UI. The problem happens when i try to make any modification to the build configuration after this, I am greeted with

java.lang.ClassCastException: "Class Name" cannot be cast to jetbrains.buildServer.buildTriggers.BuildTriggerDescriptorImpl"

Is there any way around this or is the API for adding a build trigger programatically not meant to be used?

I am using TeamCity Enterprise 6.5.4 (Evaluation license).

Thanks,
Ambuj

2 comments
Comment actions Permalink

Sorry for delay with replying.

To create build trigger descriptor you need to use jetbrains.buildServer.buildTriggers.BuildTriggerDescriptorFactory (this is a Spring bean, you can ask for it in constructor of your class).
I suppose that at the moment you create BuildTriggerDescriptorImpl by hand, without this factory, that is why the problem occurs.

We'll update javadoc and mention this factory there.

0
Comment actions Permalink

Thanks. It works perfectly.

0

Please sign in to leave a comment.