programatically enabling/disabling a build configuration

Is this possible?

I have tried setting some bogus agent requirement with SBuildType.addRequirement() and this effectively prevents the build configuration from being run, but when I go and remove the requirement with SBuildType.removeRequirement() it does not correctly reverse the effect. It shows my agent under the compatible agents list, but lists 0 as the number, and does not let me run my build configuration. If I then go and manually edit the requirements, it corrects the problem.



Is there something I am missing? Is there a better way to achieve this functionality?

Thanks!

--Steve

4 comments

The easiest way to stop triggering build configuration builds is to pause it: SBuildType.setPaused(true)

As for requirements I do not understand how you've got such behaviour, probably you can submit a code demonstrating the problem?

--
Pavel Sher

0

Hi Pavel,
Pausing the build configuration is not exactly the functionality I am looking for... The build configuration is a release build and is only run manually. What I want is to prevent the build from being run at all until some requirement has been met (e.g. a release note has been created for the build). Here is the code that caused the behavior:


Calling disable prevents the build from being run because it causes no agents to be available. Enable removes the requirement from the build configuration, but I get the behavior in the screenshot in my first post. It does not make any agents available until I manually update some requirement myself. Seems like a bug, or I am missing something here...

Thanks,

--Steve

0

You're right, there is a bug in our code, when a requirement is removed from build configuration we do not start process of compatible agents recalculation. If you modify requirements from the web UI all is working fine because project is persisted on disk and in this case we recalculate compatible agents of this project build configurations. To workaround this bug you can add the following line after the requirement removal:

buildType.getProject().persist();

--
Pavel Sher

0

Thanks!! That works perfectly.

0

Please sign in to leave a comment.