It's all about the answers!

Ask a question

BuildDefinition Save Event (Advisor or Participant)


Eduardo Bello (4401621) | asked Feb 12 '14, 11:50 a.m.
 HI All,

   Is there any extension point/operation id for save build definition event?

   I'm trying to validate some build properties and also setting some properties based on others.

    Currently I'm using "com.ibm.team.build.server.requestBuild", but I'm not able to change the build request properties. All that I can do is to retrieve an workingCopy of the build definition, change its properties and save it. Then I have to cancel the request and make a new build request programmatically (which calls the advisor one more time).


Thanks,
Bello

Accepted answer


permanent link
Nick Edgar (6.5k711) | answered Feb 12 '14, 1:47 p.m.
JAZZ DEVELOPER
Hi Eduardo, can you describe what you're trying to do at a higher level?  When issuing a build request, the APIs allow overriding the properties specified in the build definition, but it sounds like what you're trying to do is to intercept requests being made by some other client.  Modifying the build definition is probably not the best way to go.

Note that in 4.x, the operation advisor / participant for "com.ibm.team.build.server.requestBuild" are passed a com.ibm.team.build.common.model.IBuildRequestParams instance as the AdvisableOperation's operation data.  With this you could add properties to add/override in IBuildRequestParams.getNewOrModifiedBuildProperties(), to remove in getDeletedBuildProperties(). 
Eduardo Bello selected this answer as the correct answer

Comments
Eduardo Bello commented Feb 12 '14, 5:29 p.m.

 Hi Nick,


    The goal is, when any user make a build request, the advisor will check some information (what kind of build is that BF, Ant...), next it will read some information from a xml file and some information from a given workitem. Then the advisor need to change some of the build properties before send the request.

    I'd thought about two options. a) Make the changes when saving the BuildDefinition or b) Make the changes when a build is request.

    As I didn't find any way to implement option "a", I'm trying "b". 

    But,if you are saying that if I modify the properties in IBuildRequestParams.getNewOrModifiedBuildProperties(), the request will override the original properties, it will work for me. I'll give it a try.


Nick Edgar commented Feb 13 '14, 9:00 a.m. | edited Feb 13 '14, 9:01 a.m.
JAZZ DEVELOPER

if I modify the properties in IBuildRequestParams.getNewOrModifiedBuildProperties(), the request will override the original properties

Yes, but that would have to be done in an advisor, before the actual operation is run.

Another option is to add a section to the request build dialog in the UI (Eclipse UI only though).  This would also allow for user input if needed.


Eduardo Bello commented Feb 19 '14, 7:51 p.m.

It worked. I was already running it in an Advisor (op. id: com.ibm.team.build.server.requestBuild).


Now, do you know how can I  be notified if the build ended successfully or with error? 


Nick Edgar commented Feb 21 '14, 2:03 p.m.
JAZZ DEVELOPER

Good to hear.  The requests to complete a build are also Process-enabled.  That is, operations:

ITeamBuildRequestService.makeBuildComplete(IBuildResultHandle, boolean, String[])
ITeamBuildRequestService.makeBuildIncomplete(IBuildResultHandle, String[])
both run as Process-enabled operations using operation id "com.ibm.team.build.server.buildLifecycle". Unfortunately, they don't pass any info to the Process operation indicating anything about the build in question, so this isn't much use.  The only alternative I see is to periodically poll the builds you're interested in (perhaps the ones that went through your advisor).  Another option is to query for Build change events, but again that would have be run periodically, perhaps as a registered async background task like the build scheduler and pruner.  See the plugin.xml for com.ibm.team.build.service for how these are declared.


Nick Edgar commented Feb 21 '14, 2:07 p.m.
JAZZ DEVELOPER

A change event polling approach is used in the Build email notification task.  The implementation is in com.ibm.team.build.internal.service.notification.BuildNotifier, in the com.ibm.team.build.service.notification plug-in.  In addition to querying for change events to notify about since the last run, it uses sentinel change events to keep track of when it last ran.



Eduardo Bello commented Apr 15 '14, 3:41 p.m. | edited Apr 16 '14, 1:45 a.m.

 Hi @nedgar,


   I'm having a little problem. It seems that builds requested within Eclipse client calls "com.ibm.team.build.server.requestBuild" operation id and the Advisor I created. But, if I request the build from Web UI, RESP API or Java Client Libraries, the Advisor is not called. Or at least the advisor is called after BuildForge validation.

  Here is my scenario, I have a Porject on BuildForge that has some "MUST CHANGE" properties. Two of those properties are configured on demand by the Advisor I built. So the steps would be something like this:
 
   1- User fill up a property named "WorkItem ID" then request the build
   2- My java Advisor, read the work item id, searches for it, and fill up the others "MUST CHANGE" properties based on some work item information.
   3- With all properties correctly informed, the request is sent to BuildForge

 All of this works just fine when I made the request from Eclipse client. But if I use Web UI, REST API or even Java Client Libraries, the build request is sent to BuildForge right away and it returns an error that the "MUST CHANGE" properties were not informed. Because the request wouldn't call the advisor.

  What should I use to make a Build Request Advisor that is called when request were called from WebUI?

showing 5 of 6 show 1 more comments

Your answer


Register or to post your answer.