use of jetbrains.buildServer.serverSide.SBuildRunnerDescriptor in project teamcity-powershell by JetBrains.
the class PowerShellRunnerDiscovererTest method testExcludeAlreadyUsedFiles.
@Test
public void testExcludeAlreadyUsedFiles() {
final SBuildRunnerDescriptor definedRunner = m.mock(SBuildRunnerDescriptor.class, "already-defined-descriptor");
final String scriptFileName = "file1.ps1";
final Map<String, String> definedRunnerParams = new HashMap<String, String>() {
{
put(PowerShellConstants.RUNNER_SCRIPT_FILE, scriptFileName);
put(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
}
};
final Element file1 = m.mock(Element.class, "file1.ps1");
final String file2Name = "file2.ps1";
final Element file2 = m.mock(Element.class, file2Name);
m.checking(new Expectations() {
{
oneOf(myBrowser).getRoot();
will(returnValue(myRootElement));
oneOf(myRootElement).getChildren();
will(returnValue(Arrays.asList(file1, file2)));
atLeast(1).of(file1).isLeaf();
will(returnValue(true));
atLeast(1).of(file2).isLeaf();
will(returnValue(true));
atLeast(1).of(file1).getName();
will(returnValue(scriptFileName));
atLeast(1).of(file2).getName();
will(returnValue(file2Name));
atLeast(1).of(file1).getFullName();
will(returnValue(scriptFileName));
atLeast(1).of(file2).getFullName();
will(returnValue(file2Name));
atLeast(1).of(myBuildTypeSettings).getBuildRunners();
will(returnValue(Collections.singletonList(definedRunner)));
oneOf(definedRunner).getType();
will(returnValue(PowerShellConstants.RUN_TYPE));
allowing(definedRunner).getParameters();
will(returnValue(definedRunnerParams));
}
});
final List<DiscoveredObject> runners = myDiscoverer.discover(myBuildTypeSettings, myBrowser);
assertNotNull(runners);
assertEquals(1, runners.size());
validateRunner(runners.get(0), file2Name);
}
use of jetbrains.buildServer.serverSide.SBuildRunnerDescriptor in project teamcity-rest by JetBrains.
the class PropEntityStep method addToInternalMain.
@NotNull
public SBuildRunnerDescriptor addToInternalMain(@NotNull final BuildTypeSettingsEx buildType, @NotNull final ServiceLocator serviceLocator) {
if (StringUtil.isEmpty(type)) {
throw new BadRequestException("Created step cannot have empty 'type'.");
}
SBuildRunnerDescriptor similar = getInheritedOrSameIdSimilar(buildType, serviceLocator);
if (inherited != null && inherited && similar != null) {
return similar;
}
if (similar != null && id != null && id.equals(similar.getId())) {
// todo
return similar;
}
@SuppressWarnings("ConstantConditions") final SBuildRunnerDescriptor runnerToCreate = buildType.addBuildRunner(StringUtil.isEmpty(name) ? "" : name, type, properties != null ? properties.getMap() : Collections.<String, String>emptyMap());
return runnerToCreate;
}
use of jetbrains.buildServer.serverSide.SBuildRunnerDescriptor in project teamcity-rest by JetBrains.
the class PropEntitiesStep method setToBuildType.
public boolean setToBuildType(@NotNull final BuildTypeSettingsEx buildTypeSettings, @NotNull final ServiceLocator serviceLocator) {
Storage original = new Storage(buildTypeSettings);
try {
removeAllSteps(buildTypeSettings);
if (propEntities != null) {
String[] runnersOrder = new String[propEntities.size()];
boolean needToChangeOrder = false;
int i = 0;
for (PropEntityStep entity : propEntities) {
SBuildRunnerDescriptor result = entity.addToInternal(buildTypeSettings, serviceLocator);
runnersOrder[i] = result.getId();
List<SBuildRunnerDescriptor> currentRunners = buildTypeSettings.getBuildRunners();
if (!needToChangeOrder && (currentRunners.size() < i + 1 || !currentRunners.get(i).getId().equals(result.getId())))
needToChangeOrder = true;
i++;
}
if (needToChangeOrder)
buildTypeSettings.applyRunnersOrder(runnersOrder);
}
return true;
} catch (Exception e) {
// restore original settings
original.apply(buildTypeSettings);
throw new BadRequestException("Error replacing items", e);
}
}
Aggregations