Run & Tag Build via HTTP

Hello,

I would like to trigger & tag a build using http.

For both actions there are documented & undocumented action.html parameters, like
   /httpAuth/action.html?editTagsForBuild=<build id>&buildTagsInfo=<comma separated tags>
My problem is that I cannot tag a build that is still in the queue.

So would need a way to check if the build is running / finished and then tag it using the <build_id>.

Is there a way to check / get back the build_id from a build that was started using
   httpAuth/action.html?add2Queue ?

A workaround would be to move the taggin to the build script (ant) itself, but I cannot find an agent
side property for the build_id. Found it, its teamcity.buildType.id

Are there any (undocumented) queries for that ?

Thx,

Stefan

4 comments
Comment actions Permalink

Solved: I added a few lines to my "fixRunBuildParameters" Plugin


String tags = buildParams.get("system.build.mytags");

java.util.List<java.lang.String> tagList = new java.util.LinkedList<java.lang.String>();

String[] result = tags.split(",");
for (int x = 0; x < result.length; x++) {
     tagList.add(result[x]);
}
build.setTags(null, tagList);


This way I can specify the tag list when triggering the build with
     httpAuth/action.html?add2Queue=bt93&system.name=build.mytags&system.value=Tag1,Tag2,Tag3

0
Comment actions Permalink

Hi

Could not find mentioned plugin, where is it? Or this is your own custom plugin?

0
Comment actions Permalink

That's my own plugin, but it is basically just an implementation of ParametersPreprocessor like this:

public class MyParamProcessor implements
          jetbrains.buildServer.serverSide.ParametersPreprocessor {

     public static final String TAGS_PROPERTY = "system.build.tags";
 
     public void fixRunBuildParameters(SRunningBuild build,
               java.util.Map<java.lang.String, java.lang.String> runParameters,
               java.util.Map<java.lang.String, java.lang.String> buildParams) {

          try {
               if (buildParams.containsKey(TAGS_PROPERTY)) {
                    String tags = buildParams.get(TAGS_PROPERTY);

                    java.util.List<java.lang.String> tagList = new java.util.LinkedList<java.lang.String>();

                    String[] result = tags.split(",");
                    for (int x = 0; x < result.length; x++) {
                         tagList.add(result[x]);
                    }
                    build.setTags(null, tagList);
               }
          } catch (Exception e) {
               
          }

0
Comment actions Permalink

Thanks! it works for me

PS
by the way, the fixRunBuildParameters seems to be called twice
System.out.println("This is my fixRunBuildParameters") prints two lines in the TeamCity/logs/stdout_20110516.log on every run
I'm just interesting why?

(TeamCity Enterprise 6.5 EAP (build 17521) , Windows 7)

Message was edited by: Dmitry Bolshakov



Attachment(s):
TagBuildOnStart.zip
0

Please sign in to leave a comment.