Accessing BuildResult files from "Request Rebuild..." action
What I would like to do is also be able to reference those file(s) from within the "Request Rebuild..." action for our custom dialog section. In the Rebuild Dialog there is a reference to the BuildResult, which is not null. What I can't figure out is how to get a IBuildResultContext, which best I can tell is what the ResultPage uses to get access to the files associated with the BuildResult. This is passed to the ResultPage when it is constructed from how I am understanding the build source.
Is it possible to do want I am attempting?
If yes, what object/methods do I need to get the IBuildResultContext so I can get the contributions using getContributions or is this even necessary?
Is there another way of doing what I want too do?
Accepted answer
@Override
public void initializeContributionProvider(IProgressMonitor monitor) throws Exception {
IBuildRequest request = getStartRequest(getBuildResultContext().getBuildResultRecord().getBuildRequests());
if (request != null) {
fBuildProperties = request.getBuildDefinitionInstance().getProperties();
} else {
fBuildProperties = new ArrayList<IBuildProperty>();
}
}
private IBuildRequest getStartRequest(IBuildRequest[] allRequests) {
for (IBuildRequest currentRequest : allRequests) {
if (currentRequest.getBuildAction().getAction().equals(IBuildAction.REQUEST_BUILD)) {
return currentRequest;
}
}
// Log a message, but don't treat this as an error. It is unexpected,
// but we can handle it.
BuildUIPlugin.log(NLS.bind(Messages.BuildPropertiesContributionProvider_NO_REQUEST,
BuildResultTextHelper.getLabel(getBuildResultContext().getBuildResult())));
return null;
}
@Override
public AbstractBuildResultPage getBuildResultPage() {
return new BuildPropertiesPage(getBuildResultEditor(), getExtensionId(),
Messages.BuildPropertiesContributionProvider_TAB_TEXT, getExtendedContributionIds(),
getBuildResultContext(), fBuildProperties);
}
Comments
2 other answers
<extension
point="com.ibm.team.build.ui.requestBuildDialogSections">
<requestBuildDialogSection
class="com.ibm.team.build.internal.ui.dialogs.ScmOptionsSection$Factory"
order="100"/>
<requestBuildDialogSection
class="com.ibm.team.build.internal.ui.dialogs.PropertiesSection$Factory"
order="200"/>
</extension>
Comments
- query for link type contributions using com.ibm.team.build.client.ITeamBuildClient.getBuildResultContributions(IBuildResultHandle, String, IProgressMonitor), using constant com.ibm.team.build.common.model.IBuildResultContribution.LINK_EXTENDED_CONTRIBUTION_ID as the link type id
- select the one that corresponds to your custom build object, since there may be more than one link (e.g. by matching label on the IBuildResultContribution), or checking for "ftp:" prefix, or both
- you can extract the URL using com.ibm.team.build.common.model.IBuildResultContribution.getExtendedContributionProperty(String), using property name constant com.ibm.team.build.common.model.IBuildResultContribution.PROPERTY_NAME_URL