use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.
the class Build method getBuildPatchedDeps.
@NotNull
private List<SArtifactDependency> getBuildPatchedDeps(@NotNull final List<SArtifactDependency> originalDeps, final boolean useAllOriginalDeps, @NotNull final ServiceLocator serviceLocator, @NotNull final List<BuildPromotion> artifactDepsBuilds) {
List<SArtifactDependency> originalDepsCopy = useAllOriginalDeps ? new ArrayList<>(originalDeps) : null;
Map<String, Integer> processedBuildsByBuildTypeExternalId = new HashMap<>();
final ArtifactDependencyFactory artifactDependencyFactory = serviceLocator.getSingletonService(ArtifactDependencyFactory.class);
List<SArtifactDependency> result = new ArrayList<>(artifactDepsBuilds.size());
for (BuildPromotion source : artifactDepsBuilds) {
Integer buildTypeProcessedBuilds = processedBuildsByBuildTypeExternalId.get(source.getBuildTypeExternalId());
if (buildTypeProcessedBuilds == null) {
buildTypeProcessedBuilds = 0;
}
final SArtifactDependency originalDep = getArtifactDependency(originalDeps, source.getBuildType(), buildTypeProcessedBuilds);
processedBuildsByBuildTypeExternalId.put(source.getBuildTypeExternalId(), buildTypeProcessedBuilds + 1);
final SBuild associatedBuild = source.getAssociatedBuild();
final RevisionRule revisionRule = RevisionRules.newBuildIdRule(source.getId(), associatedBuild != null ? associatedBuild.getBuildNumber() : null);
final SArtifactDependency dep = artifactDependencyFactory.createArtifactDependency(source.getBuildTypeExternalId(), originalDep.getSourcePaths(), revisionRule);
dep.setCleanDestinationFolder(originalDep.isCleanDestinationFolder());
result.add(dep);
if (useAllOriginalDeps) {
originalDepsCopy.remove(originalDep);
}
}
if (useAllOriginalDeps && !originalDepsCopy.isEmpty()) {
result.addAll(originalDepsCopy);
}
return result;
}
use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.
the class BuildTypeRequestTest method testUpdatingArtifactDependencies.
@Test
public void testUpdatingArtifactDependencies() {
BuildTypeImpl buildType1 = registerBuildType("buildType1", "projectName");
BuildTypeImpl buildType2 = registerBuildType("buildType2", "projectName");
ArtifactDependencyFactory factory = myFixture.findSingletonService(ArtifactDependencyFactory.class);
assert factory != null;
SArtifactDependency dep1 = factory.createArtifactDependency(buildType2, "paths1", RevisionRules.LAST_FINISHED_RULE);
String disabledId = "id2";
SArtifactDependency dep2 = factory.createArtifactDependency(disabledId, buildType2.getExternalId(), "paths2", RevisionRules.LAST_FINISHED_RULE);
buildType1.setEnabled(disabledId, false);
SArtifactDependency dep3 = factory.createArtifactDependency(buildType2, "paths3", RevisionRules.LAST_FINISHED_RULE);
buildType1.setArtifactDependencies(Arrays.asList(dep1, dep2, dep3));
final String btLocator = "id:" + buildType1.getExternalId();
assertEquals(3, myBuildTypeRequest.getArtifactDeps(btLocator, "$long,artifact-dependencies($long)").propEntities.size());
{
PropEntityArtifactDep submitted = new PropEntityArtifactDep();
submitted.type = "artifact_dependency";
submitted.sourceBuildType = new BuildType();
submitted.sourceBuildType.setId(buildType2.getExternalId());
submitted.properties = new Properties();
submitted.properties.properties = Arrays.asList(new Property(new SimpleParameter("revisionName", "aaa"), false, Fields.LONG, myFixture), new Property(new SimpleParameter("revisionValue", "aaa"), false, Fields.LONG, myFixture), new Property(new SimpleParameter("pathRules", "aaa"), false, Fields.LONG, myFixture));
submitted.disabled = true;
String newId = myBuildTypeRequest.addArtifactDep(btLocator, "$long", submitted).id;
assertEquals(4, myBuildTypeRequest.getArtifactDeps(btLocator, "$long,artifact-dependencies($long)").propEntities.size());
assertTrue(myBuildTypeRequest.getArtifactDeps(btLocator, "$long,artifact-dependencies($long)").propEntities.get(3).disabled);
myBuildTypeRequest.deleteArtifactDep(btLocator, newId);
assertEquals(3, myBuildTypeRequest.getArtifactDeps(btLocator, "$long,artifact-dependencies($long)").propEntities.size());
}
buildType1.getSettings().addListener(new BuildTypeSettingsAdapter() {
private boolean myAlreadyThrown = false;
@Override
public void textValueChanged() {
if (!myAlreadyThrown) {
myAlreadyThrown = true;
throw new RuntimeException("I need error here ");
}
}
});
{
PropEntitiesArtifactDep submitted = new PropEntitiesArtifactDep();
PropEntityArtifactDep submitted1 = new PropEntityArtifactDep();
submitted1.type = "artifact_dependency";
submitted1.sourceBuildType = new BuildType();
submitted1.sourceBuildType.setId(buildType2.getExternalId());
submitted1.properties = new Properties();
submitted1.properties.properties = Arrays.asList(new Property(new SimpleParameter("revisionName", "aaa"), false, Fields.LONG, myFixture), new Property(new SimpleParameter("revisionValue", "aaa"), false, Fields.LONG, myFixture), new Property(new SimpleParameter("pathRules", "aaa"), false, Fields.LONG, myFixture));
submitted.propEntities = Arrays.asList(submitted1);
checkException(BadRequestException.class, new Runnable() {
public void run() {
myBuildTypeRequest.replaceArtifactDeps(btLocator, "$long", submitted);
}
}, null);
assertEquals(3, myBuildTypeRequest.getArtifactDeps(btLocator, "$long,artifact-dependencies($long)").propEntities.size());
assertEquals(3, buildType1.getArtifactDependencies().size());
assertFalse(buildType1.isEnabled(disabledId));
}
buildType1.getSettings().addListener(new BuildTypeSettingsAdapter() {
private boolean myAlreadyThrown = false;
@Override
public void textValueChanged() {
if (!myAlreadyThrown) {
myAlreadyThrown = true;
throw new RuntimeException("I need error here ");
}
}
});
{
PropEntityArtifactDep submitted = new PropEntityArtifactDep();
submitted.type = "artifact_dependency";
submitted.sourceBuildType = new BuildType();
submitted.sourceBuildType.setId(buildType2.getExternalId());
submitted.properties = new Properties();
submitted.properties.properties = Arrays.asList(new Property(new SimpleParameter("revisionName", "aaa"), false, Fields.LONG, myFixture), new Property(new SimpleParameter("revisionValue", "aaa"), false, Fields.LONG, myFixture), new Property(new SimpleParameter("pathRules", "aaa"), false, Fields.LONG, myFixture));
checkException(BadRequestException.class, new Runnable() {
public void run() {
myBuildTypeRequest.addArtifactDep(btLocator, "$long", submitted);
}
}, null);
assertEquals(3, myBuildTypeRequest.getArtifactDeps(btLocator, "$long,artifact-dependencies($long)").propEntities.size());
assertEquals(3, buildType1.getArtifactDependencies().size());
assertFalse(buildType1.isEnabled(disabledId));
}
myBuildTypeRequest.replaceArtifactDeps(btLocator, "$long", new PropEntitiesArtifactDep());
assertEquals(0, buildType1.getArtifactDependencies().size());
}
use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.
the class BuildTest method testBuildTriggeringWithTwoArtifactDepsOnSameBuildType.
@Test
public void testBuildTriggeringWithTwoArtifactDepsOnSameBuildType() {
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 build2_3 = build().in(buildType2).finish();
SFinishedBuild build3_1 = build().in(buildType3).finish();
SFinishedBuild build3_2 = build().in(buildType3).finish();
SFinishedBuild build3_3 = build().in(buildType3).finish();
SFinishedBuild build4_1 = build().in(buildType4).finish();
ArtifactDependencyFactory depsFactory = myFixture.getSingletonService(ArtifactDependencyFactory.class);
SArtifactDependency dep2_1 = depsFactory.createArtifactDependency(buildType2, "path2_1", RevisionRules.newBuildNumberRule(build2_2.getBuildNumber()));
dep2_1.setCleanDestinationFolder(true);
SArtifactDependency dep2_2 = depsFactory.createArtifactDependency(buildType2, "path2_2=>a", RevisionRules.LAST_FINISHED_RULE);
dep2_2.setCleanDestinationFolder(false);
SArtifactDependency dep3 = depsFactory.createArtifactDependency(buildType3, "path3=>b", RevisionRules.newBuildIdRule(build3_1.getBuildId(), build3_1.getBuildNumber()));
dep3.setCleanDestinationFolder(false);
buildType1.setArtifactDependencies(Arrays.asList(dep2_1, dep2_2, 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(3, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType2.getBuildTypeId(), "path2_1", true, RevisionRules.newBuildNumberRule(build2_2.getBuildNumber())), new TestArtifactDep(buildType2.getBuildTypeId(), "path2_2=>a", false, RevisionRules.LAST_FINISHED_RULE), new TestArtifactDep(buildType3.getBuildTypeId(), "path3=>b", false, RevisionRules.newBuildIdRule(build3_1.getBuildId(), build3_1.getBuildNumber())));
Builds builds1 = new Builds();
Build build1 = new Build();
build1.setLocator("id:" + build3_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build.setBuildArtifactDependencies(builds1);
result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(1, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType3.getBuildTypeId(), "path3=>b", false, RevisionRules.newBuildIdRule(build3_1.getBuildId(), build3_1.getBuildNumber())));
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build.setBuildArtifactDependencies(builds1);
result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(1, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType2.getBuildTypeId(), "path2_1", true, RevisionRules.newBuildIdRule(build2_1.getBuildId(), build2_1.getBuildNumber())));
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
Build build2 = new Build();
build2.setLocator("id:" + build2_2.getBuildId());
builds1.builds = Arrays.asList(build1, build2);
build.setBuildArtifactDependencies(builds1);
result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(2, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType2.getBuildTypeId(), "path2_1", true, RevisionRules.newBuildIdRule(build2_1.getBuildId(), build2_1.getBuildNumber())), new TestArtifactDep(buildType2.getBuildTypeId(), "path2_2=>a", false, RevisionRules.newBuildIdRule(build2_2.getBuildId(), build2_2.getBuildNumber())));
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build2 = new Build();
build2.setLocator("id:" + build2_2.getBuildId());
builds1.builds = Arrays.asList(build2, build1);
build.setBuildArtifactDependencies(builds1);
result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(2, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType2.getBuildTypeId(), "path2_1", true, RevisionRules.newBuildIdRule(build2_2.getBuildId(), build2_2.getBuildNumber())), new TestArtifactDep(buildType2.getBuildTypeId(), "path2_2=>a", false, RevisionRules.newBuildIdRule(build2_1.getBuildId(), build2_1.getBuildNumber())));
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build2 = new Build();
build2.setLocator("id:" + build2_2.getBuildId());
Build build3 = new Build();
build3.setLocator("id:" + build2_3.getBuildId());
builds1.builds = Arrays.asList(build2, build3, build1);
build.setBuildArtifactDependencies(builds1);
checkException(BadRequestException.class, new Runnable() {
public void run() {
build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
}
}, "triggering build with more builds in artifact dependencies then there are default artifact dependencies");
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build2 = new Build();
build2.setLocator("id:" + build2_2.getBuildId());
build3 = new Build();
build3.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build2, build3, build1);
build.setBuildArtifactDependencies(builds1);
PropEntitiesArtifactDep customDeps = new PropEntitiesArtifactDep();
PropEntityArtifactDep dep1 = new PropEntityArtifactDep();
dep1.properties = new Properties(createMap("revisionName", "buildId", "revisionValue", "1000", "pathRules", "path3=>x", "cleanDestinationDirectory", "true"), null, Fields.ALL_NESTED, getBeanContext(myFixture));
dep1.sourceBuildType = new BuildType();
dep1.sourceBuildType.setId(buildType2.getExternalId());
dep1.type = "artifact_dependency";
customDeps.propEntities = Arrays.asList(dep1);
build.setCustomBuildArtifactDependencies(customDeps);
checkException(BadRequestException.class, new Runnable() {
public void run() {
build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
}
}, "triggering build with more builds in artifact dependencies then there are in custom artifact dependencies");
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build2 = new Build();
build2.setLocator("id:" + build2_2.getBuildId());
builds1.builds = Arrays.asList(build1, build2);
build.setBuildArtifactDependencies(builds1);
customDeps = new PropEntitiesArtifactDep();
customDeps.setReplace("false");
build.setCustomBuildArtifactDependencies(customDeps);
result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(3, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType2.getBuildTypeId(), "path2_1", true, RevisionRules.newBuildIdRule(build2_1.getBuildId(), build2_1.getBuildNumber())), new TestArtifactDep(buildType2.getBuildTypeId(), "path2_2=>a", false, RevisionRules.newBuildIdRule(build2_2.getBuildId(), build2_2.getBuildNumber())), new TestArtifactDep(buildType3.getBuildTypeId(), "path3=>b", false, RevisionRules.newBuildIdRule(build3_1.getBuildId(), build3_1.getBuildNumber())));
builds1 = new Builds();
build1 = new Build();
build1.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build1);
build2 = new Build();
build2.setLocator("id:" + build2_2.getBuildId());
build3 = new Build();
build3.setLocator("id:" + build2_1.getBuildId());
builds1.builds = Arrays.asList(build2, build3, build1);
build.setBuildArtifactDependencies(builds1);
customDeps = new PropEntitiesArtifactDep();
dep1 = new PropEntityArtifactDep();
dep1.properties = new Properties(createMap("revisionName", "buildId", "revisionValue", "1000", "pathRules", "path3=>x", "cleanDestinationDirectory", "true"), null, Fields.ALL_NESTED, getBeanContext(myFixture));
dep1.sourceBuildType = new BuildType();
dep1.sourceBuildType.setId(buildType2.getExternalId());
dep1.type = "artifact_dependency";
customDeps.propEntities = Arrays.asList(dep1);
customDeps.setReplace("false");
build.setCustomBuildArtifactDependencies(customDeps);
result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(4, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(result.getBuildPromotion().getArtifactDependencies(), EQUALS_TEST, new TestArtifactDep(buildType2.getBuildTypeId(), "path2_1", true, RevisionRules.newBuildIdRule(build2_2.getBuildId(), build2_2.getBuildNumber())), new TestArtifactDep(buildType2.getBuildTypeId(), "path2_2=>a", false, RevisionRules.newBuildIdRule(build2_1.getBuildId(), build2_1.getBuildNumber())), new TestArtifactDep(buildType2.getBuildTypeId(), "path3=>x", true, RevisionRules.newBuildIdRule(build2_1.getBuildId(), build2_1.getBuildNumber())), new TestArtifactDep(buildType3.getBuildTypeId(), "path3=>b", false, RevisionRules.newBuildIdRule(build3_1.getBuildId(), build3_1.getBuildNumber())));
}
use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.
the class BuildTest method testBuildTriggeringWithEmptySets.
@Test
public void testBuildTriggeringWithEmptySets() {
BuildTypeImpl buildType1 = registerBuildType("buildType1", "projectName");
BuildTypeImpl buildType2 = registerBuildType("buildType2", "projectName");
ArtifactDependencyFactory depsFactory = myFixture.getSingletonService(ArtifactDependencyFactory.class);
SArtifactDependency dep2 = depsFactory.createArtifactDependency(buildType2, "path", RevisionRules.LAST_FINISHED_RULE);
buildType1.setArtifactDependencies(Arrays.asList(dep2));
buildType1.addVcsRoot(createVcsRoot("aaa", null));
buildType1.addBuildRunner("stepName", "runner", createMap("a", "b"));
buildType1.addBuildFeature("featureType", createMap("a", "b"));
buildType1.addParameter(new SimpleParameter("name", "value"));
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(1, result.getBuildPromotion().getArtifactDependencies().size());
assertEquals(1, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getVcsRootEntries().size());
assertEquals(1, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getBuildRunners().size());
assertEquals(1, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getBuildFeatures().size());
assertEquals(1, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getParameters().size());
}
// this test will actually test something only with option to copy the current settings from the build type. As so far empty build type is created, these checks check nothing
{
final Build build = new Build();
final BuildType buildTypeEntity = new BuildType();
buildTypeEntity.setId(buildType1.getExternalId());
buildTypeEntity.setArtifactDependencies(new PropEntitiesArtifactDep());
buildTypeEntity.setVcsRootEntries(new VcsRootEntries());
buildTypeEntity.setSteps(new PropEntitiesStep());
buildTypeEntity.setFeatures(new PropEntitiesFeature());
buildTypeEntity.setParameters(new Properties());
build.setBuildType(buildTypeEntity);
SQueuedBuild result = build.triggerBuild(user, myFixture, new HashMap<Long, Long>());
assertEquals(0, result.getBuildPromotion().getArtifactDependencies().size());
// these cannot be overriden so far, should actually throw exception on triggering
assertEquals(1, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getVcsRootEntries().size());
assertEquals(0, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getBuildRunners().size());
assertEquals(0, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getBuildFeatures().size());
assertEquals(0, ((BuildPromotionEx) result.getBuildPromotion()).getBuildSettings().getParameters().size());
}
}
use of jetbrains.buildServer.serverSide.artifacts.SArtifactDependency in project teamcity-rest by JetBrains.
the class BuildTypeRequestTest method testCreatingWithTemplate.
@Test
public void testCreatingWithTemplate() {
// see also alike setup in BuildTypeTest.testInheritance()
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_FAIL_IF_TESTS_FAIL, 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.addParameter(new SimpleParameter("a30", "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_FAIL_IF_TESTS_FAIL, false);
{
// hack to reproduce case related to https://youtrack.jetbrains.com/issue/TW-45273
// comment until TW-45273 is fixed t10.setOption(BuildTypeOptions.BT_FAIL_IF_TESTS_FAIL, false);
}
bt10.setOption(BuildTypeOptions.BT_CHECKOUT_DIR, "checkout_bt");
bt10.setOption(BuildTypeOptions.BT_CHECKOUT_MODE, "ON_SERVER");
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", "b"));
bt10.addParameter(new SimpleParameter("a40", "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!
// get buildType
BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt10), new Fields("$long"), getBeanContext(myServer));
// post buildType to create new one
buildType.initializeSubmittedFromUsual();
buildType.setId("bt10_copy");
buildType.setName("bt 10 - copy");
BuildType buildType_copy = myBuildTypeRequest.addBuildType(buildType, Fields.LONG.getFieldsSpec());
// compare initial and new buildType
BuildTypeImpl bt10_copy = myFixture.getProjectManager().findBuildTypeByExternalId("bt10_copy");
assertNotNull(bt10_copy);
assertNull(BuildTypeUtil.compareBuildTypes(bt10.getSettings(), bt10_copy.getSettings(), true, false));
// todo:
// check different settings in submitted from the inherited one, but with inherited flag
// check submitting with different enabled state
// check submitting with different id
}
Aggregations