Build Feature Plugin

Answered

Hello,

 

So, i'm building a new plugin for teamcity as a Build Feature.

Right now I have it being triggered like this. With a listener for the buildFinished.

public BuildStatusListener(@NotNull final EventDispatcher<BuildServerListener> listener,
@NotNull final ChangeStatusUpdater updater)
{
this.updater = updater;
listener.addListener(new BuildServerAdapter()
{

@Override
public void buildFinished(SRunningBuild build)
{
runStuff(build);
}
});
}

And inside I basically iterate through the build features to check if my feature is active.

for (SBuildFeatureDescriptor feature : buildType.getResolvedSettings().getBuildFeatures())
{
if (!feature.getType().equals(myFeature.FEATURE_TYPE))
{
continue;
}

Now, is there a better way to do this? I don't really like this approach. Seems a bit hammered.

I don't want my code to be executed after every single build. Is there a listener or trigger that only applies IF my Build Feature is active?

Thanks,

3 comments
Comment actions Permalink
Official comment

Hi Ee10170, this is how it is to be done at the moment. One thing (looking at the code): please consider that the user may add more than one build feature of your type to her build configuration.

Comment actions Permalink

Hi Anton Zamolotskikh.

Thanks for the quick reply and the suggestion.

Multiple features of the same type will not make sense in my scenario but I will add a check for that.

0
Comment actions Permalink

If that's the case, you can override isMultipleFeaturesPerBuildTypeAllowed() in BuildFeature to return false. TeamCity will not allow to add more than one such feature to a config then.

0

Please sign in to leave a comment.