use of com.thoughtworks.go.domain.BuildCommand in project gocd by gocd.
the class BuildSessionCancelingTest method cancelTaskShouldBeProcessedBeforeKillChildProcess.
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void cancelTaskShouldBeProcessedBeforeKillChildProcess() throws InterruptedException {
final BuildSession buildSession = newBuildSession();
final BuildCommand printSubProcessCount = exec("/bin/bash", "-c", "pgrep -P " + new JavaSysMon().currentPid() + " | wc -l");
Thread buildingThread = new Thread(new Runnable() {
@Override
public void run() {
buildSession.build(compose(compose(execSleepScript(50), echo("after sleep")).setOnCancel(printSubProcessCount)));
}
});
buildingThread.start();
waitUntilSubProcessExists(execSleepScriptProcessCommand(), true);
assertTrue(buildInfo(), buildSession.cancel(30, TimeUnit.SECONDS));
waitUntilSubProcessExists(execSleepScriptProcessCommand(), false);
assertThat(Integer.parseInt(console.lastLine().trim()), greaterThan(0));
buildingThread.join();
}
use of com.thoughtworks.go.domain.BuildCommand in project gocd by gocd.
the class BuildComposer method harvestProperties.
private BuildCommand harvestProperties() {
List<ArtifactPropertiesGenerator> generators = assignment.getPlan().getPropertyGenerators();
List<BuildCommand> commands = new ArrayList<>();
for (ArtifactPropertiesGenerator generator : generators) {
BuildCommand command = BuildCommand.generateProperty(generator.getName(), generator.getSrc(), generator.getXpath()).setWorkingDirectory(workingDirectory());
commands.add(command);
}
return BuildCommand.compose(reportAction("Start to create properties"), BuildCommand.compose(commands));
}
use of com.thoughtworks.go.domain.BuildCommand in project gocd by gocd.
the class BuildComposer method setupEnvironmentVariables.
private BuildCommand setupEnvironmentVariables() {
EnvironmentVariableContext context = environmentVariableContext();
ArrayList<BuildCommand> commands = new ArrayList<>();
commands.add(export("GO_SERVER_URL"));
for (String property : context.getPropertyKeys()) {
commands.add(export(property, context.getProperty(property), context.isPropertySecure(property)));
}
return BuildCommand.compose(commands);
}
use of com.thoughtworks.go.domain.BuildCommand in project gocd by gocd.
the class TestCommandExecutor method captureSubCommandOutput.
private String captureSubCommandOutput(BuildCommand command, BuildSession buildSession) {
BuildCommand targetCommand = command.getSubCommands().get(0);
ConsoleCapture consoleCapture = new ConsoleCapture();
buildSession.newTestingSession(consoleCapture).processCommand(targetCommand);
return consoleCapture.captured();
}
use of com.thoughtworks.go.domain.BuildCommand in project gocd by gocd.
the class CommandBuilder method buildCommand.
@Override
public BuildCommand buildCommand() {
String[] argsArray = CommandLine.translateCommandLine(args);
BuildCommand exec = BuildCommand.exec(command, argsArray);
if (workingDir != null) {
exec.setWorkingDirectory(workingDir.getPath());
}
return exec;
}
Aggregations