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";
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();
}
}
}
Hope it helps!
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.Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Mar 03 '16, 1:46 a.m.