Search in sources :

Example 1 with SArtifactDependency

use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.

the class BuildTest method testBuildTriggeringWithArtifactDeps.

@Test
public void testBuildTriggeringWithArtifactDeps() {
    BuildTypeImpl buildType1 = registerBuildType("buildType1", "projectName");
    BuildTypeImpl buildType2 = registerBuildType("buildType2", "projectName");
    BuildTypeImpl buildType3 = registerBuildType("buildType3", "projectName");
    BuildTypeImpl buildType4 = registerBuildType("buildType4", "projectName");
    SFinishedBuild build2_1 = build().in(buildType2).finish();
    SFinishedBuild build2_2 = build().in(buildType2).finish();
    SFinishedBuild build3_1 = build().in(buildType3).finish();
    SFinishedBuild build3_2 = build().in(buildType3).finish();
    SFinishedBuild build4_1 = build().in(buildType4).finish();
    ArtifactDependencyFactory depsFactory = myFixture.getSingletonService(ArtifactDependencyFactory.class);
    SArtifactDependency dep2 = depsFactory.createArtifactDependency(buildType2, "path", RevisionRules.LAST_FINISHED_RULE);
    dep2.setCleanDestinationFolder(true);
    SArtifactDependency dep3 = depsFactory.createArtifactDependency(buildType3, "path2", RevisionRules.newBuildIdRule(build3_1.getBuildId(), build3_1.getBuildNumber()));
    dep3.setCleanDestinationFolder(false);
    buildType1.setArtifactDependencies(Arrays.asList(dep2, dep3));
    final SUser user = getOrCreateUser("user");
    // end of setup
    final Build build = new Build();
    final BuildType buildTypeEntity = new BuildType();
    buildTypeEntity.setId(buildType1.getExternalId());
    build.setBuildType(buildTypeEntity);
    SQueuedBuild result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
    assertEquals(2, result.getBuildPromotion().getArtifactDependencies().size());
    assertEquals(buildType2.getId(), result.getBuildPromotion().getArtifactDependencies().get(0).getSourceBuildTypeId());
    assertEquals("latest.lastFinished", result.getBuildPromotion().getArtifactDependencies().get(0).getRevisionRule().getRevision());
    assertEquals(buildType3.getId(), result.getBuildPromotion().getArtifactDependencies().get(1).getSourceBuildTypeId());
    assertEquals(build3_1.getBuildId() + ".tcbuildid", result.getBuildPromotion().getArtifactDependencies().get(1).getRevisionRule().getRevision());
    Builds builds1 = new Builds();
    Build build1 = new Build();
    build1.setLocator("buildType:(id:" + buildType3.getExternalId() + "),number:" + build3_2.getBuildNumber());
    builds1.builds = Arrays.asList(build1);
    build.setBuildArtifactDependencies(builds1);
    result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
    assertEquals(1, result.getBuildPromotion().getArtifactDependencies().size());
    assertEquals(buildType3.getId(), result.getBuildPromotion().getArtifactDependencies().get(0).getSourceBuildTypeId());
    assertEquals(build3_2.getBuildId() + ".tcbuildid", result.getBuildPromotion().getArtifactDependencies().get(0).getRevisionRule().getRevision());
    Builds builds2 = new Builds();
    Build build2 = new Build();
    build2.setLocator("buildType:(id:" + buildType4.getExternalId() + "),number:" + build4_1.getBuildNumber());
    builds2.builds = Arrays.asList(build2);
    build.setBuildArtifactDependencies(builds2);
    checkException(BadRequestException.class, new Runnable() {

        public void run() {
            build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
        }
    }, "triggering build with artifact dependency not in default artifact dependencies");
    build.setBuildArtifactDependencies(builds1);
    PropEntitiesArtifactDep propEntitiesArtifactDep1 = new PropEntitiesArtifactDep();
    propEntitiesArtifactDep1.setReplace("false");
    build.setCustomBuildArtifactDependencies(propEntitiesArtifactDep1);
    result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
    assertEquals(2, result.getBuildPromotion().getArtifactDependencies().size());
    assertEquals(buildType3.getId(), result.getBuildPromotion().getArtifactDependencies().get(0).getSourceBuildTypeId());
    assertEquals(build3_2.getBuildId() + ".tcbuildid", result.getBuildPromotion().getArtifactDependencies().get(0).getRevisionRule().getRevision());
    assertEquals(buildType2.getId(), result.getBuildPromotion().getArtifactDependencies().get(1).getSourceBuildTypeId());
    assertEquals("latest.lastFinished", result.getBuildPromotion().getArtifactDependencies().get(1).getRevisionRule().getRevision());
    PropEntitiesArtifactDep propEntitiesArtifactDep2 = new PropEntitiesArtifactDep();
    PropEntityArtifactDep propEntityArtifactDep1 = new PropEntityArtifactDep();
    propEntityArtifactDep1.properties = new Properties(createMap("revisionName", "buildId", "revisionValue", "1000", "pathRules", "path3", "cleanDestinationDirectory", "true"), null, Fields.ALL_NESTED, getBeanContext(myFixture));
    propEntityArtifactDep1.sourceBuildType = new BuildType();
    propEntityArtifactDep1.sourceBuildType.setId(buildType4.getExternalId());
    propEntityArtifactDep1.type = "artifact_dependency";
    propEntitiesArtifactDep2.propEntities = Arrays.asList(propEntityArtifactDep1);
    build.setCustomBuildArtifactDependencies(propEntitiesArtifactDep2);
    checkException(BadRequestException.class, new Runnable() {

        public void run() {
            build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
        }
    }, "triggering build with artifact dependency not in posted custom-artifact-dependnecies");
    build.setBuildArtifactDependencies(null);
    result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
    assertEquals(1, result.getBuildPromotion().getArtifactDependencies().size());
    assertEquals(buildType4.getId(), result.getBuildPromotion().getArtifactDependencies().get(0).getSourceBuildTypeId());
    assertEquals("1000" + ".tcbuildid", result.getBuildPromotion().getArtifactDependencies().get(0).getRevisionRule().getRevision());
    assertEquals("path3", result.getBuildPromotion().getArtifactDependencies().get(0).getSourcePaths());
    assertEquals(true, result.getBuildPromotion().getArtifactDependencies().get(0).isCleanDestinationFolder());
    build.setBuildArtifactDependencies(builds2);
    result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
    assertEquals(1, result.getBuildPromotion().getArtifactDependencies().size());
    assertEquals(buildType4.getId(), result.getBuildPromotion().getArtifactDependencies().get(0).getSourceBuildTypeId());
    assertEquals(build4_1.getBuildId() + ".tcbuildid", result.getBuildPromotion().getArtifactDependencies().get(0).getRevisionRule().getRevision());
    propEntitiesArtifactDep2.setReplace("false");
    build.setCustomBuildArtifactDependencies(propEntitiesArtifactDep2);
    result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
    assertEquals(3, result.getBuildPromotion().getArtifactDependencies().size());
}
Also used : Builds(jetbrains.buildServer.server.rest.model.build.Builds) SUser(jetbrains.buildServer.users.SUser) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) Build(jetbrains.buildServer.server.rest.model.build.Build) Test(org.testng.annotations.Test) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 2 with SArtifactDependency

use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.

the class BuildTypeTest method testInheritance.

@Test
public void testInheritance() {
    // see also alike setup in BuildTypeRequestTest.testCreatingWithTemplate()
    ProjectEx project10 = createProject("project10", "project 10");
    MockVcsSupport vcs = vcsSupport().withName("vcs").dagBased(true).register();
    final SVcsRoot vcsRoot10 = project10.createVcsRoot("vcs", "extId10", "name10");
    final SVcsRoot vcsRoot20 = project10.createVcsRoot("vcs", "extId20", "name20");
    final SVcsRoot vcsRoot30 = project10.createVcsRoot("vcs", "extId30", "name30");
    project10.addParameter(new SimpleParameter("p", "v"));
    BuildTypeEx bt100 = project10.createBuildType("bt100", "bt 100");
    BuildTypeEx bt110 = project10.createBuildType("bt110", "bt 110");
    BuildTypeEx bt120 = project10.createBuildType("bt120", "bt 120");
    // TEMPLATE
    BuildTypeTemplate t10 = project10.createBuildTypeTemplate("t10", "bt 10");
    t10.setArtifactPaths("aaaaa");
    t10.setBuildNumberPattern("pattern");
    t10.setOption(BuildTypeOptions.BT_ALLOW_EXTERNAL_STATUS, true);
    t10.setOption(BuildTypeOptions.BT_CHECKOUT_DIR, "checkout_t");
    t10.setOption(BuildTypeOptions.BT_CHECKOUT_MODE, "ON_AGENT");
    t10.setOption(BuildTypeOptions.BT_FAIL_ON_ANY_ERROR_MESSAGE, true);
    t10.setOption(BuildTypeOptions.BT_EXECUTION_TIMEOUT, 11);
    t10.addVcsRoot(vcsRoot10);
    t10.addVcsRoot(vcsRoot20);
    t10.setCheckoutRules(vcsRoot20, new CheckoutRules("a=>b"));
    BuildRunnerDescriptorFactory runnerDescriptorFactory = myFixture.getSingletonService(BuildRunnerDescriptorFactory.class);
    t10.addBuildRunner(runnerDescriptorFactory.createBuildRunner(project10, "run10", "name10", "Ant1", map("a", "b")));
    t10.addBuildRunner(runnerDescriptorFactory.createBuildRunner(project10, "run20", "name20", "Ant2", map("a", "b")));
    BuildTriggerDescriptor trigger10 = t10.addBuildTrigger("Type", map("a", "b"));
    BuildTriggerDescriptor trigger20 = t10.addBuildTrigger("Type", map("a", "b"));
    t10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f10", "type", map("a", "b")));
    t10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f20", "type", map("a", "b")));
    t10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f30", "type", map("a", "b")));
    ArtifactDependencyFactory artifactDependencyFactory = myFixture.getSingletonService(ArtifactDependencyFactory.class);
    ArrayList<SArtifactDependency> artifactDeps = new ArrayList<>();
    artifactDeps.add(artifactDependencyFactory.createArtifactDependency("art10", bt100.getExternalId(), "path1", RevisionRules.LAST_PINNED_RULE));
    artifactDeps.add(artifactDependencyFactory.createArtifactDependency("art20", bt100.getExternalId(), "path2", RevisionRules.LAST_PINNED_RULE));
    artifactDeps.add(artifactDependencyFactory.createArtifactDependency("art30", bt100.getExternalId(), "path3", RevisionRules.LAST_PINNED_RULE));
    t10.setArtifactDependencies(artifactDeps);
    t10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt100));
    t10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt110));
    t10.addParameter(new SimpleParameter("a10", "b"));
    t10.addParameter(new SimpleParameter("a20", "b"));
    t10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req10", "a", null, RequirementType.EXISTS));
    t10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req20", "b", null, RequirementType.EXISTS));
    t10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req30", "c", null, RequirementType.EXISTS));
    // BUILD TYPE
    BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
    bt10.attachToTemplate(t10);
    // todo: test w/o override
    bt10.setArtifactPaths("bbbb");
    bt10.setOption(BuildTypeOptions.BT_ALLOW_EXTERNAL_STATUS, false);
    bt10.setOption(BuildTypeOptions.BT_CHECKOUT_DIR, "checkout_bt");
    bt10.setOption(BuildTypeOptions.BT_CHECKOUT_MODE, "ON_AGENT");
    bt10.setOption(BuildTypeOptions.BT_EXECUTION_TIMEOUT, 17);
    bt10.addVcsRoot(vcsRoot20);
    bt10.setCheckoutRules(vcsRoot20, new CheckoutRules("x=>y"));
    bt10.addVcsRoot(vcsRoot30);
    bt10.setEnabled("run20", false);
    bt10.addBuildRunner(runnerDescriptorFactory.createBuildRunner(project10, "run30", "name30", "Ant30", map("a", "b")));
    bt10.setEnabled(trigger20.getId(), false);
    BuildTriggerDescriptor trigger30 = bt10.addBuildTrigger("Type", map("a", "b"));
    bt10.setEnabled("f20", false);
    bt10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f30", "type_bt", map("a", "b")));
    bt10.addBuildFeature(myFixture.getBuildFeatureDescriptorFactory().createBuildFeature("f40", "type", map("a", "b")));
    ArrayList<SArtifactDependency> artifactDepsBt = new ArrayList<>();
    artifactDepsBt.add(artifactDependencyFactory.createArtifactDependency("art30", bt100.getExternalId(), "path30", RevisionRules.LAST_FINISHED_RULE));
    artifactDepsBt.add(artifactDependencyFactory.createArtifactDependency("art40", bt100.getExternalId(), "path4", RevisionRules.LAST_PINNED_RULE));
    bt10.setArtifactDependencies(artifactDepsBt);
    bt10.setEnabled("art20", false);
    bt10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt110));
    bt10.addDependency(myFixture.getSingletonService(DependencyFactory.class).createDependency(bt120));
    bt10.addParameter(new SimpleParameter("a20", "x"));
    bt10.addParameter(new SimpleParameter("a30", "x"));
    bt10.setEnabled("req20", false);
    bt10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req30", "x", null, RequirementType.EQUALS));
    bt10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("req40", "y", null, RequirementType.EXISTS));
    // NOW, TEST TIME!
    BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt10), new Fields("$long"), myBeanContext);
    parameterEquals(find(buildType.getSettings().properties, "artifactRules"), "artifactRules", "bbbb", null);
    parameterEquals(find(buildType.getSettings().properties, "buildNumberPattern"), "buildNumberPattern", "pattern", true);
    parameterEquals(find(buildType.getSettings().properties, "allowExternalStatus"), "allowExternalStatus", "false", null);
    parameterEquals(find(buildType.getSettings().properties, "checkoutDirectory"), "checkoutDirectory", "checkout_bt", null);
    // parameterEquals(find(buildType.getSettings().properties, "checkoutMode"), "checkoutMode", "ON_AGENT", null); //option set to the same value in bt - API does not make difference so far
    parameterEquals(find(buildType.getSettings().properties, "shouldFailBuildOnAnyErrorMessage"), "shouldFailBuildOnAnyErrorMessage", "true", true);
    parameterEquals(find(buildType.getSettings().properties, "executionTimeoutMin"), "executionTimeoutMin", "17", null);
    // default value
    assertNull(find(buildType.getSettings().properties, "showDependenciesChanges"));
    assertEquals(3, buildType.getVcsRootEntries().vcsRootAssignments.size());
    vcsRootEntryEquals(buildType.getVcsRootEntries().vcsRootAssignments.get(0), vcsRoot10.getExternalId(), "", true);
    // bt modifications are ignored
    vcsRootEntryEquals(buildType.getVcsRootEntries().vcsRootAssignments.get(1), vcsRoot20.getExternalId(), "a=>b", true);
    vcsRootEntryEquals(buildType.getVcsRootEntries().vcsRootAssignments.get(2), vcsRoot30.getExternalId(), "", null);
    assertEquals(3, buildType.getSteps().propEntities.size());
    stepsEquals(buildType.getSteps().propEntities.get(0), "run10", "Ant1", null, true);
    stepsEquals(buildType.getSteps().propEntities.get(1), "run20", "Ant2", false, true);
    stepsEquals(buildType.getSteps().propEntities.get(2), "run30", "Ant30", null, null);
    // TeamCity issue: order of some entities depends on where the trigger is defined (build type or template)
    assertEquals(3, buildType.getTriggers().propEntities.size());
    stepsEquals(buildType.getTriggers().propEntities.get(0), trigger30.getId(), "Type", null, null);
    stepsEquals(buildType.getTriggers().propEntities.get(1), trigger10.getId(), "Type", null, true);
    stepsEquals(buildType.getTriggers().propEntities.get(2), trigger20.getId(), "Type", false, true);
    assertEquals(4, buildType.getFeatures().propEntities.size());
    stepsEquals(buildType.getFeatures().propEntities.get(0), "f30", "type_bt", null, null);
    stepsEquals(buildType.getFeatures().propEntities.get(1), "f40", "type", null, null);
    stepsEquals(buildType.getFeatures().propEntities.get(2), "f10", "type", null, true);
    stepsEquals(buildType.getFeatures().propEntities.get(3), "f20", "type", false, true);
    assertEquals(4, buildType.getArtifactDependencies().propEntities.size());
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(0), "art30", "artifact_dependency", null, null);
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(1), "art40", "artifact_dependency", null, null);
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(2), "art10", "artifact_dependency", null, true);
    stepsEquals(buildType.getArtifactDependencies().propEntities.get(3), "art20", "artifact_dependency", false, true);
    assertEquals(3, buildType.getSnapshotDependencies().propEntities.size());
    stepsEquals(buildType.getSnapshotDependencies().propEntities.get(0), bt100.getExternalId(), "snapshot_dependency", null, true);
    stepsEquals(buildType.getSnapshotDependencies().propEntities.get(1), bt110.getExternalId(), "snapshot_dependency", null, true);
    stepsEquals(buildType.getSnapshotDependencies().propEntities.get(2), bt120.getExternalId(), "snapshot_dependency", null, null);
    assertEquals(4, buildType.getParameters().properties.size());
    parameterEquals(buildType.getParameters().properties.get(0), "a10", "b", true);
    parameterEquals(buildType.getParameters().properties.get(1), "a20", "x", null);
    parameterEquals(buildType.getParameters().properties.get(2), "a30", "x", null);
    parameterEquals(buildType.getParameters().properties.get(3), "p", "v", true);
    assertEquals(4, buildType.getAgentRequirements().propEntities.size());
    stepsEquals(buildType.getAgentRequirements().propEntities.get(0), "req30", "equals", null, null);
    stepsEquals(buildType.getAgentRequirements().propEntities.get(1), "req40", "exists", null, null);
    stepsEquals(buildType.getAgentRequirements().propEntities.get(2), "req10", "exists", null, true);
    stepsEquals(buildType.getAgentRequirements().propEntities.get(3), "req20", "exists", false, true);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) ArrayList(java.util.ArrayList) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) BuildTriggerDescriptor(jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor) SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 3 with SArtifactDependency

use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.

the class BuildTypeRequest method getArtifactDependency.

public static SArtifactDependency getArtifactDependency(@NotNull final BuildTypeOrTemplate buildType, @NotNull final String artifactDepLocator) {
    if (StringUtil.isEmpty(artifactDepLocator)) {
        throw new BadRequestException("Empty artifact dependency locator is not supported.");
    }
    final Locator locator = new Locator(artifactDepLocator, "id", Locator.LOCATOR_SINGLE_VALUE_UNUSED_NAME);
    final String artifactDepId;
    if (locator.isSingleValue()) {
        artifactDepId = locator.getSingleValue();
    } else {
        artifactDepId = locator.getSingleDimensionValue("id");
    }
    locator.checkLocatorFullyProcessed();
    if (StringUtil.isEmpty(artifactDepId)) {
        throw new BadRequestException("Cannot find id in artifact dependency locator '" + artifactDepLocator + "'");
    }
    for (SArtifactDependency dep : buildType.get().getArtifactDependencies()) {
        if (artifactDepId.equals(dep.getId())) {
            return dep;
        }
    }
    try {
        final Integer orderNumber = Integer.parseInt(artifactDepId);
        try {
            SArtifactDependency result = buildType.get().getArtifactDependencies().get(orderNumber);
            LOG.debug("Found artifact dependency by order number " + orderNumber + " instead of id. This behavior is obsolete, use id (" + result.getId() + ") instead of order number.");
            return result;
        } catch (IndexOutOfBoundsException e) {
            throw new NotFoundException("Could not find artifact dependency by id '" + artifactDepId + "' in " + buildType.getText() + " with id '" + buildType.getId() + "'");
        }
    } catch (NumberFormatException e) {
        // not a number either: report error:
        throw new NotFoundException("Could not find artifact dependency by id '" + artifactDepId + "' in " + buildType.getText() + " with id '" + buildType.getId() + "'");
    }
}
Also used : ServiceLocator(jetbrains.buildServer.ServiceLocator) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)

Example 4 with SArtifactDependency

use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.

the class BuildTypeRequest method replaceArtifactDep.

@PUT
@Path("/{btLocator}/artifact-dependencies/{artifactDepLocator}")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update an artifact dependency of the matching build configuration.", nickname = "replaceArtifactDependency")
public PropEntityArtifactDep replaceArtifactDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @PathParam("artifactDepLocator") String artifactDepLocator, @QueryParam("fields") String fields, PropEntityArtifactDep description) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    final SArtifactDependency newDependency = description.replaceIn(buildType.getSettingsEx(), getArtifactDependency(buildType, artifactDepLocator), myServiceLocator);
    buildType.persist("Artifact dependency replaced");
    return new PropEntityArtifactDep(newDependency, 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) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with SArtifactDependency

use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.

the class BuildTypeRequest method addArtifactDep.

@POST
@Path("/{btLocator}/artifact-dependencies")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Add an artifact dependency to the matching build configuration.", nickname = "addArtifactDependencyToBuildType")
public PropEntityArtifactDep addArtifactDep(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @QueryParam("fields") String fields, PropEntityArtifactDep description) {
    final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
    final SArtifactDependency result = description.addTo(buildType.getSettingsEx(), myServiceLocator);
    buildType.persist("Artifact dependency added");
    return new PropEntityArtifactDep(result, 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) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)19 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)8 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)7 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)6 Test (org.testng.annotations.Test)6 ApiOperation (io.swagger.annotations.ApiOperation)5 NotNull (org.jetbrains.annotations.NotNull)5 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)4 Build (jetbrains.buildServer.server.rest.model.build.Build)3 BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)3 SUser (jetbrains.buildServer.users.SUser)3 ArrayList (java.util.ArrayList)2 BuildTriggerDescriptor (jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor)2 Builds (jetbrains.buildServer.server.rest.model.build.Builds)2 AccessDeniedException (jetbrains.buildServer.serverSide.auth.AccessDeniedException)2 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)2 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)2 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)2 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)2 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)2