How to get Owner of a Build Definition from RTC side via RTC API
2 answers
From the IBuildDefinition it is possible to get the IProcessAreaHandle directly, which is a superinterface of both IProjectAreaHandle and ITeamAreaHandle.
The example below is complete and will print the unique UUID of the Process Area. The same you would see in the Project/Team Area URI.
Edit:
As Ralph Schoon mentioned, you cannot assign a USER as owner of a Build Definition. Instead, you can set an area (Project Area or Team Area) where it's visible and its users are allowed to modify/delete it based on roles and privileges assigned.
In RTC, some elements can be assigned to users and project/team areas (i.e. Components), only users (i.e. Repository Workspace) or only project/team areas (i.e. Streams).
The example below is complete and will print the unique UUID of the Process Area. The same you would see in the Project/Team Area URI.
public class Main { public static void main(String[] args) { IProgressMonitor myProgressMonitor = new NullProgressMonitor(); final String userId = "abc0de";Hope it helps!
final String password = "********";
String repoUri = "https://server.com/ccm/";
TeamPlatform.startup();
try { ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri); repo.registerLoginHandler(new ILoginHandler2() {
@Override public ILoginInfo2 challenge(ITeamRepository repo) {
return new UsernameAndPasswordLoginInfo(userId, password);
}
});
repo.login(myProgressMonitor);
/* Use the repo to get the build client library */ ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class); /* Get the build definition for "My Build Definition" */ IBuildDefinition definition = buildClient.getBuildDefinition("My Build Definition", myProgressMonitor);
IProcessAreaHandle processAreaHandle = definition.getProcessArea();
System.out.println(processAreaHandle.getItemId());
repo.logout();
}
catch (TeamRepositoryException e) {e.printStackTrace();}
finally {
TeamPlatform.shutdown();
}
}
}
Edit:
As Ralph Schoon mentioned, you cannot assign a USER as owner of a Build Definition. Instead, you can set an area (Project Area or Team Area) where it's visible and its users are allowed to modify/delete it based on roles and privileges assigned.
In RTC, some elements can be assigned to users and project/team areas (i.e. Components), only users (i.e. Repository Workspace) or only project/team areas (i.e. Streams).
Comments
han huynh
Mar 03 '16, 1:46 a.m.Thanks Ralph Schoon and Rafael Rezende for your answers.
I can pull the Process Area and the build definitions from RTC via API, but unfortunately I don't still see OWNER of the build definition or the project area.
Should the RTC team provide us the way to get the build owner?
Thanks for your support.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Mar 03 '16, 1:46 a.m.As already stated:
I am not aware of the concept of an owner for a build definition other than it is in a project area. So please provide us with a useful description what the owner of a build definition should be and where we should be able to see it in the RTC UI. If you can't show it in the UI, it is likely not there at all.