How to programatically enable/disable a build step ?

I am implenting a controller to create builds according to a fairly simple set of rules.  I have created a largish template with multiple steps and now want to enable/disable builds steps on the fly

In my controller I am using SBuildType to access the runner collection via SBuildType.getBuildRunners();  So far so good.

The problem is that thre are no methods to enable/disable the various runners.  I had a peek at the properties collection and I have three of them:

teamcity.step.mode looked like a candidate but I can only find the following property name:


which appears to only have the following allowable values:




Can anyone let me know how to do this?

I am using TC 7.1 build 23907

Comment actions Permalink

Hi Stuart,

You can look up the code in REST API plugin, see changeStepSetting in and setSetting in
Basically you need the method

BTW, you might consider making your plugin public so that other users can benefit and contribute.

Comment actions Permalink

Great I will give this a bash thanks for the pointer.  I'll report back with the approach when it works.

I can't publish the plugin as I work in a bank and that would break confidentiality rules.  However, I can share techniques and happy to contribute to the forum.

Thanks again

Comment actions Permalink

Yep worked a treat.  I built a wrapper class to access it which others may find useful:

public class SBuildTypeExt {     protected SBuildType myBuildType;     public   SBuildTypeExt(SBuildType sBuildType)     {         if (sBuildType == null)             throw new NullPointerException("Null sBuildType passed to SBuildTypeExt");         myBuildType = sBuildType;     }         public SBuildType getBuildType()     {         return myBuildType;     }     public boolean isFromTemplate(String name)     {         SBuildType bType = getBuildType();         if (bType.isTemplateBased() &&             bType.getTemplate().getName().equals(name))             return true;         else             return false;     }     public void enableStep(String stepName, Boolean enable)     {         for (SBuildRunnerDescriptor desc : myBuildType.getBuildRunners())         {             if (desc.getName().equals(stepName))             {                 myBuildType.setEnabled(desc.getId(), enable);                 return;             }         }     }     public boolean isStepEnabled(String stepName)     {         for (SBuildRunnerDescriptor desc : myBuildType.getBuildRunners())         {             if (desc.getName().equals(stepName))             {                 return myBuildType.isEnabled(desc.getId());             }         }         return false;     }


Thanks for the assist

Please sign in to leave a comment.