Search in sources :

Example 1 with BuildProblemData

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));
}
Also used : BuildProblemData(jetbrains.buildServer.BuildProblemData) ProblemOccurrence(jetbrains.buildServer.server.rest.model.problem.ProblemOccurrence) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with BuildProblemData

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));
}
Also used : SessionUser(jetbrains.buildServer.web.util.SessionUser) SUser(jetbrains.buildServer.users.SUser) User(jetbrains.buildServer.users.User) BuildProblemData(jetbrains.buildServer.BuildProblemData) ProblemOccurrence(jetbrains.buildServer.server.rest.model.problem.ProblemOccurrence) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 BuildProblemData (jetbrains.buildServer.BuildProblemData)2 ProblemOccurrence (jetbrains.buildServer.server.rest.model.problem.ProblemOccurrence)2 SUser (jetbrains.buildServer.users.SUser)1 User (jetbrains.buildServer.users.User)1 SessionUser (jetbrains.buildServer.web.util.SessionUser)1