Custom Build from an extended tab

Hello,

I'm writing a plugin to TeamCity and I would like to do the following things.

  1. Create an extended tab that shows certain options (our internal logic) in an extended tab. (This is actually done.)
  2. List available build agents on the extended tab. (How do I get a list of build agents?)
  3. List available parameters on the same tab. (How to I get a list of parameters?)
  4. When user clicks on "Run" button on the extended tab, it gathers the parameter values and build agent(s) and runs the build. (How do I execute builds using TeamCity APIs?)


I'm sorry if I jammed too many questions in one thread.

3 comments
Comment actions Permalink

Hello,

I suppose you know build configuration where you want to start a build. If this is the case, you can obtain list of agents which can run build of this build configuration using method:
SBuildType#getCanRunAndCompatibleAgents(boolean includeDisabled)

Not sure what parameters do you need, but if you happen to know build configuration where you start build, you can use this method:
SBuildType#getParameters()

This method will return complete map of parameters configured for build configuration, including parameters inherited from projects and templates.

As to triggering builds, there are a few methods. First of all, to trigger a build with the same settings as in SBuildType you can use this method:
SBuildType#addToQueue(requestor);

Where requestor is a string describing who triggered this build. It can be arbitrary string.

But since you're asking about parameters I suppose you need to start customized build, i.e. build with custom parameters. In this case it is better to use BuildCustomizer. Something like this:

 
jetbrains.buildServer.serverSide.BuildCustomizerFactory customizerFactory; // Spring bean
BuildCustomizer customizer = customizerFactory.createBuildCustomizer(buildType, null);
customizer.setParameters(customParams);
BuildPromotion p = customizer.createBuildPromotion();
p.addToQueue(requestor); // or p.addToQueue(agent, requestor) if you want to start build on specific agent
0
Comment actions Permalink

Hello,

I've actually figured them all out just yesterday but I still appreciate your reply. :)

The APIs are nicely organized that I was able to figure things out. I'm quite impressed how extendable TeamCity is. I do have different questions, but I will create another thread so that the question  won't get mixed up with this one.

Thanks

0
Comment actions Permalink

Hi Hayato,

 

Can I ask if this plugin is being used personally or will you be sharing it? We are looking for the exact same functionality without looking into develop a plugin/extended the current one.

 

Thank you

0

Please sign in to leave a comment.