Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Retrieve properties from a build request

Hi, I'm developing a pre-condition plugin on Request build operation. I'd like to retrieve a specific property of the build. I've tried the method IBuildDefinition.getProperty and it runs but gets only the default value of the BuildDefinition and not a new value insert by the user which requires the build.

I've already find this kind of problem, but in that case I've resolved it using IBuildResult.getBuildRequests() and IBuildRequst.getBuildDefinitionProperties() methods. In this case I was expecting that operation data return by request operation was IBuildRequest but now I've discovered that is IBuildDefinition and so I cannot use the previous method.
How can I get the new value of the property insert by a user requesting a build?

0 votes



10 answers

Permanent link
Hi, I have the same problem.
I'm expecting to find the new values for the properties from the field "operation", but I don't know how it is possible.
Any help?


Hi, I'm developing a pre-condition plugin on Request build operation. I'd like to retrieve a specific property of the build. I've tried the method IBuildDefinition.getProperty and it runs but gets only the default value of the BuildDefinition and not a new value insert by the user which requires the build.

I've already find this kind of problem, but in that case I've resolved it using IBuildResult.getBuildRequests() and IBuildRequst.getBuildDefinitionProperties() methods. In this case I was expecting that operation data return by request operation was IBuildRequest but now I've discovered that is IBuildDefinition and so I cannot use the previous method.
How can I get the new value of the property insert by a user requesting a build?

0 votes


Permanent link
Nobody has already had this problem?? Any idea on how can I retrieve the new build property?

I'm quite blocked on this point, so any help will be appreciate...

0 votes


Permanent link
Yes, to get the properties for a build, you follow: IBuildResult.getBuildRequests() -> IBuildRequest.getBuildDefinitionInstance() -> IBuildDefinitionInstance.getProperties().

Or you can use the helper methods:
IBuildRequest.getBuildDefinitionProperties(): returns a map of the properties (computed each time)
IBuildDefinitionInstance.getProperty(String): look up a given property (O(N) search)

The IBuildDefinitionInstance captures the state of the build definition and its properties, plus any property changes, at the time of the request.

> In this case I was expecting that operation data return by request operation was IBuildRequest but now I've discovered that is IBuildDefinition and so I cannot use the previous method.

Which API method are you using? ITeamBuildRequestClient.requestBuild returns the IBuildRequest, as does getNextRequest.

0 votes


Permanent link
Yes, to get the properties for a build, you follow: IBuildResult.getBuildRequests() -> IBuildRequest.getBuildDefinitionInstance() -> IBuildDefinitionInstance.getProperties().

Or you can use the helper methods:
IBuildRequest.getBuildDefinitionProperties(): returns a map of the properties (computed each time)
IBuildDefinitionInstance.getProperty(String): look up a given property (O(N) search)

The IBuildDefinitionInstance captures the state of the build definition and its properties, plus any property changes, at the time of the request.

> In this case I was expecting that operation data return by request operation was IBuildRequest but now I've discovered that is IBuildDefinition and so I cannot use the previous method.

Which API method are you using? ITeamBuildRequestClient.requestBuild returns the IBuildRequest, as does getNextRequest.


Thank you very much for the answer.
Unfortunately I can't use the method from IBuildResult because I've not got this object. I've already tried this way and it works correctly. But in this case I'm developing a pre-condition plugin so the only thing I got is the AdvisableOperation.getOperationData() method which gives me an IBuildDefinition object. So my problem is how to get IBuildRequest or IBuildDefinitionInstance (which I'had not seen before, thank you) from this IBuildDefinition object.

Or, maybe, there is another method of AdvisableOperation which can give me the new properties information.

0 votes


Permanent link
Using debug I also see that AdvisableOperation given by the system (operation) contains the information I need in a private variable named "val$newOrModifiedBuildProperties" but I'm not able to retrieve it using methods...

0 votes


Permanent link
Oh, I see the problem. The issue is that at the time your advisor (aka precondition) gets called, the build request hasn't been created yet. The only Buildspecific information it has is the handle to the build definition.

The code in question, in TeamBuildRequestService.requestBuild does:

IProcessArea processArea = getProcessArea(buildDefinitionHandle);
IProcessServerService processService = (IProcessServerService) getService(IProcessServerService.class);
IServerProcess serverProcess = processService.getServerProcess(processArea);

IOperationReport report = serverProcess.adviseAndExecute(new AdvisableOperation(
ProcessConstants.REQUEST_BUILD_OPERATION_ID, buildDefinitionHandle, processArea) {
public IOperationReport run(IBehaviorConfiguration configuration, IProgressMonitor monitor)
throws TeamRepositoryException {
IBuildRequest buildRequest = requestBuildWithoutProcess(buildDefinitionHandle,
newOrModifiedBuildProperties, deletedBuildProperties, allowDuplicateRequests, personalBuild);


The second argument to the AdvisableOperation constructor is the operationData argument, and currently we only pass the buildDefinitionHandle.

For you to get the info you want, we would need to pass a richer object encapsulating the build definition handle and the other arguments to requestBuild, such as the new/modified properties and the properties to remove. Or alternatively, we could compute the resulting set of properties and pass that (still before creating the build result, in case the precondition fails).

If you need this support, please file an enhancement request against RTC/Build.

0 votes


Permanent link
The private variable val$newOrModifiedBuildProperties is generated by the Java compiler, since the newOrModifiedBuildProperties argument is accessed from within the AdvisableOperation anonymous subclass. It's certainly not part of the API, though you could try accessing it using a reflection hack, e.g.

Field field = advisableOperation.getClass().getDeclaredField("val$newOrModifiedBuildProperties");
field.setAccessible(true);
String[] newOrModifiedProps = (String[]) field.get(advisableOperation);
.

0 votes


Permanent link
Thank you very much for your useful answer, I'm finally able to retrieve this operation. For everyone else which could have this problem this is the snippet (the only difference with the previous one is the type of object):

Field field = operation.getClass().getDeclaredField("val$newOrModifiedBuildProperties");
field.setAccessible(true);
IBuildProperty[] newProps = (IBuildProperty[])field.get(operation);


I've also open an enhancement on this point, as you have suggested, because I think this could be very useful on pre-condition plugins creation.
The link is:
https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=94006

0 votes


Permanent link
Glad you were able to get it working, but note that this is a horrendous hack, and is fragile. E.g. your code would be broken if we simply were to rename the newOrModifiedBuildProperties parameter (normally parameter names have no impact on API). So please ensure you have appropriate checks or try/catch blocks in your code, and fall back to safe behaviour (e.g. just checking the build definition properties) if there's a problem.

0 votes


Permanent link
Yes, I know. Unfortunately I have other class which uses internal stuff, so I must be attent to new release modify.

Thanks again, best regards,
Michele.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937

Question asked: Aug 31 '09, 6:56 a.m.

Question was seen: 8,274 times

Last updated: Aug 31 '09, 6:56 a.m.

Confirmation Cancel Confirm