use of jetbrains.buildServer.BuildProblemData in project teamcity-rest by JetBrains.
the class BuildRequest method addProblem.
/**
* Experimental.
* Allows to add a build problem to the build. The only used attributes of the submitted problem are identity, type, details, additionalData
*/
@POST
@Path("/{buildLocator}/problemOccurrences")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "addProblem", nickname = "addProblem", hidden = true)
public ProblemOccurrence addProblem(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, ProblemOccurrence problemOccurrence, @QueryParam("fields") String fields) {
BuildPromotion buildPromotion = myBuildFinder.getBuildPromotion(null, buildLocator);
checkBuildOperationPermission(buildPromotion);
SBuild build = buildPromotion.getAssociatedBuild();
if (build == null) {
throw new NotFoundException("No finished build associated with promotion id " + buildPromotion.getId());
}
BuildProblemData problemDetails = problemOccurrence.getFromPosted(myBeanContext.getServiceLocator());
build.addBuildProblem(problemDetails);
return new ProblemOccurrence(myBeanContext.getSingletonService(ProblemOccurrenceFinder.class).getProblem(build, problemDetails), myBeanContext, new Fields(fields));
}
use of jetbrains.buildServer.BuildProblemData in project teamcity-rest by JetBrains.
the class BuildRequest method addProblemToBuild.
/**
* Experimental.
* Adds a build problem with given details. The same as marking the build as failed from UI.
*/
@POST
@Path("/{buildLocator}/problemOccurrences")
@Consumes({ "text/plain" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Add a build problem to the matching build.", nickname = "addProblemToBuild")
public ProblemOccurrence addProblemToBuild(@ApiParam(format = LocatorName.BUILD) @PathParam("buildLocator") String buildLocator, String problemDetails, @QueryParam("fields") String fields) {
BuildPromotion buildPromotion = myBuildFinder.getBuildPromotion(null, buildLocator);
SBuild build = buildPromotion.getAssociatedBuild();
if (build == null) {
throw new NotFoundException("No finished build associated with promotion id " + buildPromotion.getId());
}
User user = myPermissionChecker.getCurrent().getAssociatedUser();
if (user == null) {
throw new BadRequestException("Cannot perform operation: no current user");
}
BuildProblemData problemData = build.addUserBuildProblem((SUser) user, problemDetails);
return new ProblemOccurrence(myBeanContext.getSingletonService(ProblemOccurrenceFinder.class).getProblem(build, problemData), myBeanContext, new Fields(fields));
}
Aggregations