Add "Clean all files before build " programtically

Hi,

I want to add the "Clean all files before build " flag to a jetbrains.buildServer.serverSide.SBuildType

I saw there is a method  boolean isCleanBuild(); but no setter.

I tried setOption(new BooleanOption("cleanBuild", true),true) but nothing happened.

Also, I need to add "swabra.mode", "swabra.after.build", but I guess it is done the same way since in the project-config.xml they both appear under options

Thanks.

3 comments
Comment actions Permalink

Try:
buildType.setOption(SBuildType.BT_CLEAN_BUILD, true);

If you want this option to be persisted, add this too:
buildType.getProject().persist();

"swabra.mode" and "swabra.after.build" are runner parameters (i.e. parameters which should be passed to build runner on the agent), to set them use:
buildType.addRunParameter(new SimpleParameter("swabra.mode", "true"));

BTW if Swabra plugin is enabled there is no need to set clean build option.

0
Comment actions Permalink

Thanks a lot, that works.
Now I am close to a final version and I come across other problems.

How to add General settings -> Build number format  programaticaly ?

How to add on a VcsTrigger "Build Trigger Rules":Trigger patterns:-> "-:user=build:pom.xml" ?

0
Comment actions Permalink

To update build number pattern use:

buildType.getBuildNumbers().setBuildNumberPattern(pattern)
buildType.getBuildNumbers().persist();

As for VcsTrigger - this is not a part of open API, and most likely will change in the future (in fact VcsTrigger API has already changed in 5.0). But if you really need it you can do the following:
// iterate over build type triggers and find jetbrains.buildServer.buildTriggers.vcs.VcsTrigger using instanceof
buildType.getBuildTriggers()

// use method setIncludeRules() to set collection of rules:
vcsTrigger.setIncludeRules(list<string>)

Note that this method is named differently in 5.0.

Do not forget to call persist after the settings change.

0

Please sign in to leave a comment.