[closed] How to create an IBuildProperty object
The question has been closed for the following reason: "The question is answered, right answer was accepted" by rschoon Dec 11 '16, 6:15 a.m.
Accepted answer
We would add a new build property to some existing build definitions using a Plain Java Client.
We are able:
- to create the new build property:
String buildPropName = ...
String buildPropValue = ...
IBuildProperty buildProp = BuildItemFactory.createBuildProperty();
buildProp.setKind(IBuildProperty.PROPERTY_KIND_STRING);
buildProp.setName(buildPropName);
buildProp.setValue(buildPropValue); - to retrieve the build definition:
ITeamRepository repo = ...
ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
String buildDefId = ...
IBuildDefinition buildDef = buildClient.getBuildDefinition(buildDefId, null);
How can we now add IBuildProperty buildProp to IBuildDefinition buildDef?
Thanks in advance.
7 other answers
You can also use:
com.ibm.team.build.common.model.IBuildDefinition.setProperty(String, String)
which will add the property if not already there, or override its value if it is.
It still needs to be called on a working copy of the item.
@Kelvin, you asked:
> Could we use IBuildProperty to set the Repository Workspace (for personal build) which is under the Build Options section?
Yes, when you request a personal build, it overrides the "team.scm.workspaceUUID" property with the item id for the selected developer workspace. This is the same property used for non-personal builds (as indicated in the description for the workspace field in the SCM page of the build definition). In the case of a personal build, its value just gets changed to refer to the selected workspace.
Comments
showing 5 of 9
show 4 more comments
Hi,
I have wrote server side API to trigger build on work item save.
Also I am passing worksitem id to build as Property.
I have created string type of property “workItemId” in build definition, now I have to pass the value for this property with workitem id.
Could you please suggest some solution, I tried with below code but while creating IBuildProperties[1], I am getting IBuildProperties cannot be resolved to a variable error message
IBuildProperty buildProp = BuildItemFactory.createBuildProperty();
buildProp.setName("workItemId");
buildProp.setValue("31");
buildProp.setKind(IBuildProperty.PROPERTY_KIND_STRING);
IBuildProperties[1]= buildProp;
ITeamBuildRequestService brService = getService(ITeamBuildRequestService.class);
IItemsResponse response = brService.requestBuild(buildDef, IBuildProperties[1], null,true, false);
Comments
1 vote
Looks like there is no custom constructor, so you would just do a normal new operation.. and then set the fields thru the set methods.
IBuildProperty x = new IBuildProperty();
x.setName(...);
x.setValue(....);
x.setDescription(...);
x.setKind(....);
x.setRequired(true/false);
also, 3.0.1.1 javadoc is now available.. very helpful overall.
Sam
IBuildProperty x = new IBuildProperty();
x.setName(...);
x.setValue(....);
x.setDescription(...);
x.setKind(....);
x.setRequired(true/false);
also, 3.0.1.1 javadoc is now available.. very helpful overall.
Sam