This Question is Answered

2 "helpful" answers available (2 pts)
7 Replies Last post: Dec 29, 2011 9:52 PM by Pavel Sher  
Simone  Busoli Novice 201 posts since
Jun 20, 2005
Currently Being Moderated

Sep 5, 2010 2:13 PM

How to run a custom build from the API

Hi, is it possible to run a build with custom options (like in the custom run dialog) from the API? I only see the addToQueue methods on SBuildType although TC supports doing that from http.

Pavel Sher JetBrains 2,148 posts since
Mar 6, 2008
Currently Being Moderated
Sep 8, 2010 7:08 PM in response to: Simone Busoli
Re: How to run a custom build from the API

Sorry for delay. There is no Open API for custom builds at this time. If you really need it, you can try to do the following:

// obtain BuildPromotion object from the build configuration

BuildPromotionEx promo = ((BuildTypeEx)buildType).createBuildPromotion();

// use setUserBuildParameters() to set custom parameters to build promotion (note you cannot remove parameters, just override them and add new)

promo.setUserBuildParameters(customParams);

// use setCustomArtifactDependencies() if you need to override artifact deps

 

promo.setBuildComment(user, comment); // this sets comment to the build

 

// after that you can add promotion to the queue

promo.addToQueue("my custom build");

 

If you want to build on a specific change, this may not be easy because revisions need to be calculated properly.

Mark Baker Newbie 65 posts since
Sep 8, 2010
Currently Being Moderated
Sep 22, 2010 3:18 PM in response to: Pavel Sher
Re: How to run a custom build from the API

I am trying to do a similar thing - pass parameters to a build from a custom Build Trigger plugin.

 

I can't seem to find BuildPromotionEx or BuildTypeEx -- which modules are these imported from?

 

Many thanks,


Mark

Yegor Yarko JetBrains 1,458 posts since
May 5, 2004
Currently Being Moderated
Sep 22, 2010 3:32 PM in response to: Mark Baker
Re: How to run a custom build from the API

Mark,

 

You will need to add <TeamCity server home>\webapps\ROOT\WEB-INF\lib\server.jar as a library of your plugin project.

BTW, I filed a request to add a way to put builds into the queue into open API.

Mark Baker Newbie 65 posts since
Sep 8, 2010
Currently Being Moderated
Sep 22, 2010 4:06 PM in response to: Yegor Yarko
Re: How to run a custom build from the API

Hi Yeggor,

 

That's great! I have this working now, so I am very happy :-)

 

Cheers,

 

Mark

Johan Björk Newbie 34 posts since
May 3, 2011
Currently Being Moderated
Dec 29, 2011 5:11 PM in response to: Mark Baker
Re: How to run a custom build from the API

Hi guys,

 

I'm trying to do something similar, but I also need to mark the build as a 'personal build', any ideas how to do this?

 

(I'm doing the above solution and it works fine, but I haven't found a way to set it as personal)

 

Thanks

/Johan

 

**Update**

Found it, works by doing:

BuildPromotionEx promo = ((BuildTypeEx)bt).createPersonalBuildType(getUser(httpServletRequest)).createBuildPromotion();

Pavel Sher JetBrains 2,148 posts since
Mar 6, 2008
Currently Being Moderated
Dec 29, 2011 9:52 PM in response to: Johan Björk
Re: How to run a custom build from the API

Hopefully, we'll have a better API in 7.0 version.

More Like This

  • Retrieving data ...