use of jetbrains.buildServer.controllers.actions.ChangeBuildStatusProcessor in project teamcity-rest by JetBrains.
the class BuildRequest method setBuildStatus.
@POST
@Path("/{buildLocator}/status")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Change status of the build.", nickname = "setBuildStatus")
public Response setBuildStatus(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, @QueryParam("fields") String fields, BuildStatusUpdate statusUpdate, @Context HttpServletRequest request) {
BuildPromotion build = myBuildPromotionFinder.getItem(buildLocator);
AuthorityHolder authorityHolder = myBeanContext.getSingletonService(SecurityContext.class).getAuthorityHolder();
ChangeBuildStatusProcessor processor = new ChangeBuildStatusProcessor(build.getAssociatedBuild(), (SUser) authorityHolder.getAssociatedUser(), statusUpdate.status, statusUpdate.comment);
ActionErrors errors = processor.doChangeStatus();
if (errors.hasErrors()) {
List<String> errorStrings = new ArrayList<>();
for (ActionErrors.Error e : errors.getErrors()) {
errorStrings.add(e.getMessage());
}
return Response.status(Response.Status.BAD_REQUEST).entity(new BuildStatusUpdateResult(build, errorStrings, new Fields(fields), myBeanContext)).build();
}
return Response.ok().entity(new BuildStatusUpdateResult(build, Collections.emptyList(), new Fields(fields), myBeanContext)).build();
}
Aggregations