Search in sources :

Example 1 with BuildSession

use of com.thoughtworks.go.buildsession.BuildSession in project gocd by gocd.

the class AgentWebSocketClientController method cancelBuild.

private void cancelBuild() throws InterruptedException {
    BuildSession build = this.buildSession.get();
    if (build == null) {
        return;
    }
    getAgentRuntimeInfo().cancel();
    if (!build.cancel(30, TimeUnit.SECONDS)) {
        LOG.error("Waited 30 seconds for canceling job finish, but the job is still running. Maybe canceling job does not work as expected, here is buildSession details: " + buildSession.get());
    }
}
Also used : BuildSession(com.thoughtworks.go.buildsession.BuildSession)

Example 2 with BuildSession

use of com.thoughtworks.go.buildsession.BuildSession in project gocd by gocd.

the class AgentWebSocketClientController method runBuild.

private void runBuild(BuildSettings buildSettings) {
    URLService urlService = new URLService();
    StreamConsumer buildConsole;
    if (getSystemEnvironment().isConsoleLogsThroughWebsocketEnabled()) {
        buildConsole = new ConsoleOutputWebsocketTransmitter(webSocketSessionHandler, buildSettings.getBuildId());
    } else {
        buildConsole = new ConsoleOutputTransmitter(new RemoteConsoleAppender(urlService.prefixPartialUrl(buildSettings.getConsoleUrl()), httpService));
    }
    ArtifactsRepository artifactsRepository = new UrlBasedArtifactsRepository(httpService, urlService.prefixPartialUrl(buildSettings.getArtifactUploadBaseUrl()), urlService.prefixPartialUrl(buildSettings.getPropertyBaseUrl()), new ZipUtil());
    DefaultBuildStateReporter buildStateReporter = new DefaultBuildStateReporter(webSocketSessionHandler, getAgentRuntimeInfo());
    TimeProvider clock = new TimeProvider();
    BuildVariables buildVariables = new BuildVariables(getAgentRuntimeInfo(), clock);
    BuildSession build = new BuildSession(buildSettings.getBuildId(), buildStateReporter, buildConsole, buildVariables, artifactsRepository, httpService, clock, new File("."));
    this.buildSession.set(build);
    build.setEnv("GO_SERVER_URL", getSystemEnvironment().getServiceUrl());
    getAgentRuntimeInfo().idle();
    try {
        getAgentRuntimeInfo().busy(new AgentBuildingInfo(buildSettings.getBuildLocatorForDisplay(), buildSettings.getBuildLocator()));
        build.build(buildSettings.getBuildCommand());
    } finally {
        try {
            buildConsole.stop();
        } finally {
            getAgentRuntimeInfo().idle();
        }
    }
    this.buildSession.set(null);
}
Also used : StreamConsumer(com.thoughtworks.go.util.command.StreamConsumer) AgentBuildingInfo(com.thoughtworks.go.server.service.AgentBuildingInfo) BuildSession(com.thoughtworks.go.buildsession.BuildSession) ConsoleOutputTransmitter(com.thoughtworks.go.remote.work.ConsoleOutputTransmitter) RemoteConsoleAppender(com.thoughtworks.go.remote.work.RemoteConsoleAppender) ArtifactsRepository(com.thoughtworks.go.buildsession.ArtifactsRepository) BuildVariables(com.thoughtworks.go.buildsession.BuildVariables) File(java.io.File)

Example 3 with BuildSession

use of com.thoughtworks.go.buildsession.BuildSession in project gocd by gocd.

the class GitMaterialUpdaterTest method updateTo.

private void updateTo(GitMaterial material, RevisionContext revisionContext, JobResult expectedResult) {
    BuildSession buildSession = newBuildSession();
    JobResult result = buildSession.build(new GitMaterialUpdater(material).updateTo("working", revisionContext));
    assertThat(buildInfo(), result, is(expectedResult));
}
Also used : JobResult(com.thoughtworks.go.domain.JobResult) BuildSession(com.thoughtworks.go.buildsession.BuildSession) GitMaterialUpdater(com.thoughtworks.go.domain.materials.git.GitMaterialUpdater)

Aggregations

BuildSession (com.thoughtworks.go.buildsession.BuildSession)3 ArtifactsRepository (com.thoughtworks.go.buildsession.ArtifactsRepository)1 BuildVariables (com.thoughtworks.go.buildsession.BuildVariables)1 JobResult (com.thoughtworks.go.domain.JobResult)1 GitMaterialUpdater (com.thoughtworks.go.domain.materials.git.GitMaterialUpdater)1 ConsoleOutputTransmitter (com.thoughtworks.go.remote.work.ConsoleOutputTransmitter)1 RemoteConsoleAppender (com.thoughtworks.go.remote.work.RemoteConsoleAppender)1 AgentBuildingInfo (com.thoughtworks.go.server.service.AgentBuildingInfo)1 StreamConsumer (com.thoughtworks.go.util.command.StreamConsumer)1 File (java.io.File)1