Search in sources :

Example 6 with Dependency

use of jetbrains.buildServer.serverSide.dependency.Dependency in project teamcity-rest by JetBrains.

the class BuildTypeRequest method deleteSnapshotDep.

@DELETE
@Path("/{btLocator}/snapshot-dependencies/{snapshotDepLocator}")
@ApiOperation(value = "Delete a snapshot dependency of the matching build configuration.", nickname = "deleteSnapshotDependency")
public void deleteSnapshotDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @PathParam("snapshotDepLocator") String snapshotDepLocator) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    final Dependency dependency = PropEntitySnapshotDep.getSnapshotDep(buildType.get(), snapshotDepLocator, myBuildTypeFinder);
    PropEntitySnapshotDep.removeFrom(buildType.get(), dependency);
    buildType.persist("Snapshot dependency removed");
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) Dependency(jetbrains.buildServer.serverSide.dependency.Dependency) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with Dependency

use of jetbrains.buildServer.serverSide.dependency.Dependency in project teamcity-rest by JetBrains.

the class BuildTypeRequest method getSnapshotDep.

@GET
@Path("/{btLocator}/snapshot-dependencies/{snapshotDepLocator}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get a snapshot dependency of the matching build configuration.", nickname = "getSnapshotDependency")
public PropEntitySnapshotDep getSnapshotDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @PathParam("snapshotDepLocator") String snapshotDepLocator, @QueryParam("fields") String fields) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    final Dependency dependency = PropEntitySnapshotDep.getSnapshotDep(buildType.get(), snapshotDepLocator, myBuildTypeFinder);
    return new PropEntitySnapshotDep(dependency, buildType.getSettingsEx(), new Fields(fields), new BeanContext(myFactory, myServiceLocator, myApiUrlBuilder));
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BeanContext(jetbrains.buildServer.server.rest.util.BeanContext) Dependency(jetbrains.buildServer.serverSide.dependency.Dependency) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Example 8 with Dependency

use of jetbrains.buildServer.serverSide.dependency.Dependency in project teamcity-rest by JetBrains.

the class BuildPromotionFinderTest method testSnapshotDependenciesProblems.

@Test
public void testSnapshotDependenciesProblems() {
    final SProject project = createProject("prj", "project");
    final BuildTypeEx buildConfA = (BuildTypeEx) project.createBuildType("buildConfA", "buildConfA");
    final BuildTypeEx buildConfB1 = (BuildTypeEx) project.createBuildType("buildConfB1", "buildConfB1");
    final BuildTypeEx buildConfB2 = (BuildTypeEx) project.createBuildType("buildConfB2", "buildConfB2");
    final BuildTypeEx buildConfC = (BuildTypeEx) project.createBuildType("buildConfC", "buildConfC");
    addDependency(buildConfB1, buildConfA).setOption(DependencyOptions.RUN_BUILD_IF_DEPENDENCY_FAILED, DependencyOptions.BuildContinuationMode.RUN_ADD_PROBLEM);
    addDependency(buildConfB2, buildConfA).setOption(DependencyOptions.RUN_BUILD_IF_DEPENDENCY_FAILED, DependencyOptions.BuildContinuationMode.RUN_ADD_PROBLEM);
    addDependency(buildConfC, buildConfB1).setOption(DependencyOptions.RUN_BUILD_IF_DEPENDENCY_FAILED, DependencyOptions.BuildContinuationMode.RUN_ADD_PROBLEM);
    addDependency(buildConfC, buildConfB2).setOption(DependencyOptions.RUN_BUILD_IF_DEPENDENCY_FAILED, DependencyOptions.BuildContinuationMode.RUN_ADD_PROBLEM);
    {
        BuildPromotion buildA = build().in(buildConfA).withProblem(BuildProblemData.createBuildProblem("problem1", "problemType", "problem descr")).finish().getBuildPromotion();
        BuildPromotion buildB1 = build().in(buildConfB1).withProblem(BuildProblemData.createBuildProblem("problem21", "problemType", "problem descr2")).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildB2 = build().in(buildConfB2).withProblem(BuildProblemData.createBuildProblem("problem22", "problemType", "problem descr2")).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildC = build().in(buildConfC).withProblem(BuildProblemData.createBuildProblem("problem3", "problemType", "problem descr3")).snapshotDepends(buildB1, buildB2).finish().getBuildPromotion();
        check(null, buildC, buildB2, buildB1, buildA);
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))", buildB2, buildB1, buildA);
        check("snapshotDependencyProblem:(from:(id:" + buildB1.getId() + "))", buildC);
        check("snapshotDependencyProblem:(from:(id:" + buildA.getId() + "))", buildC, buildB2, buildB1);
        checkProblemOccurrences("build:(snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))),type:(snapshotDependencyProblem:false)", "problem22", "problem21", "problem1");
        buildC.getAssociatedBuild().muteBuildProblems(createUser("u"), true, "");
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))");
        checkProblemOccurrences("build:(snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))),type:(snapshotDependencyProblem:false)");
    }
    {
        BuildPromotion buildA = build().in(buildConfA).withProblem(BuildProblemData.createBuildProblem("problem1", "problemType", "problem descr")).finish().getBuildPromotion();
        BuildPromotion buildB1 = build().in(buildConfB1).withProblem(BuildProblemData.createBuildProblem("problem21", "problemType", "problem descr2")).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildB2 = build().in(buildConfB2).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildC = build().in(buildConfC).snapshotDepends(buildB1, buildB2).finish().getBuildPromotion();
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))", buildB2, buildB1, buildA);
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "),includeInitial:true)", buildC, buildB2, buildB1, buildA);
        check("id:" + buildB2.getId() + ",snapshotDependencyProblem:(to:(id:" + buildC.getId() + "),includeInitial:true)", buildB2);
        checkProblemOccurrences("build:(snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))),type:(snapshotDependencyProblem:false)", "problem21", "problem1");
    }
    {
        BuildPromotion buildA = build().in(buildConfA).withProblem(BuildProblemData.createBuildProblem("problem1", "problemType", "problem descr")).finish().getBuildPromotion();
        BuildPromotion buildB1 = build().in(buildConfB1).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildB2 = build().in(buildConfB2).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildC = build().in(buildConfC).snapshotDepends(buildB1, buildB2).finish().getBuildPromotion();
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))", buildB2, buildB1, buildA);
        checkProblemOccurrences("build:(snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))),type:(snapshotDependencyProblem:false)", "problem1");
    }
    Dependency depCB2 = buildConfC.getDependencies().stream().filter(d -> buildConfB2.equals(d.getDependOn())).findAny().get();
    depCB2.setOption(DependencyOptions.RUN_BUILD_IF_DEPENDENCY_FAILED, DependencyOptions.BuildContinuationMode.RUN);
    {
        BuildPromotion buildA = build().in(buildConfA).withProblem(BuildProblemData.createBuildProblem("problem1", "problemType", "problem descr")).finish().getBuildPromotion();
        BuildPromotion buildB1 = build().in(buildConfB1).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildB2 = build().in(buildConfB2).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildC = build().in(buildConfC).snapshotDepends(buildB1, buildB2).finish().getBuildPromotion();
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))", buildB1, buildA);
        checkProblemOccurrences("build:(snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))),type:(snapshotDependencyProblem:false)", "problem1");
    }
    depCB2.setOption(DependencyOptions.RUN_BUILD_IF_DEPENDENCY_FAILED, DependencyOptions.BuildContinuationMode.MAKE_FAILED_TO_START);
    {
        BuildPromotion buildA = build().in(buildConfA).withProblem(BuildProblemData.createBuildProblem("problem1", "problemType", "problem descr")).finish().getBuildPromotion();
        BuildPromotion buildB1 = build().in(buildConfB1).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildB2 = build().in(buildConfB2).snapshotDepends(buildA).finish().getBuildPromotion();
        BuildPromotion buildC = build().in(buildConfC).snapshotDepends(buildB1, buildB2).finish().getBuildPromotion();
        check("snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))", buildB2, buildB1, buildA);
        checkProblemOccurrences("build:(snapshotDependencyProblem:(to:(id:" + buildC.getId() + "))),type:(snapshotDependencyProblem:false)", "problem1");
    }
}
Also used : Dependency(jetbrains.buildServer.serverSide.dependency.Dependency) Test(org.testng.annotations.Test)

Aggregations

Dependency (jetbrains.buildServer.serverSide.dependency.Dependency)8 ApiOperation (io.swagger.annotations.ApiOperation)4 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)4 SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)4 BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)3 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)2 DependencyFactory (jetbrains.buildServer.serverSide.dependency.DependencyFactory)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 BuildTypeFinder (jetbrains.buildServer.server.rest.data.BuildTypeFinder)1 Locator (jetbrains.buildServer.server.rest.data.Locator)1 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)1 CyclicDependencyFoundException (jetbrains.buildServer.serverSide.dependency.CyclicDependencyFoundException)1 NotNull (org.jetbrains.annotations.NotNull)1 SkipException (org.testng.SkipException)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1