Plugin Configuration

What is the correct/proper/best way to store configuration options for a plugin?

Also, is it possible to change the default VCS trigger quiet period from a plugin (i.e. from code)?

0
2 comments

If settings of the plugin can be edited by user then it is better to store them in the <TeamCity data path>/config directory. Various caches shall be stored in the <TeamCity data path>/system/caches directory. You can use jetbrains.buildServer.serverSide.ServerPaths bean to obtain these paths.

As for VCS trigger, there is no open API for changing quiet period. However you can obtain build triggers from the build configuration: SBuildType::getBuildTriggers() method and check whether  BuildTrigger can be casted to jetbrains.buildServer.buildTriggers.vcs.VcsTrigger. In VcsTrigger there are two methods:
setQuietPeriod(int quietPeriodInMunites)
setQuietPeriodMode(quietPeriodMode)

After the change build configuration settings must be persisted, use SBuildType.getProject().persist() method.

--
Pavel Sher

0

Ah, brilliant. I was able to store my configuration using JDOM in the configuration directory returned by SBuildServer.getConfigDir().

The reason I was asking about changing the default VCS trigger quiet period was that I was trying to develop a way to temporarily disable the continuous builds. We use TeamCity to manage the build and deployment of our server software into QA and production. It works quite nicely, but it the continuous builds can get in the way when you are trying to deploy some fixes and there are 30 builds in the queue that were triggered by your fix. I was thinking that changing the quiet period to some large value would do the trick. However, I found a better way to get the result I wanted by creating a build server listener and removing the build from the queue in buildTypeAddedToQueue if the continuous builds were disabled and the build was triggered automatically. This works perfectly and I added a page extension to ALL_PAGES_HEADER that shows the current enabled/disabled status. It works perfectly!

0

Please sign in to leave a comment.