Search in sources :

Example 1 with BuildSettings

use of com.thoughtworks.go.domain.BuildSettings in project gocd by gocd.

the class AgentWebSocketClientController method process.

void process(Message message) throws InterruptedException {
    switch(message.getAction()) {
        case cancelBuild:
            cancelJobIfThereIsOneRunning();
            cancelBuild();
            break;
        case setCookie:
            String cookie = MessageEncoding.decodeData(message.getData(), String.class);
            getAgentRuntimeInfo().setCookie(cookie);
            LOG.info("Got cookie: {}", cookie);
            break;
        case assignWork:
            cancelJobIfThereIsOneRunning();
            Work work = MessageEncoding.decodeWork(message.getData());
            LOG.debug("Got work from server: [{}]", work.description());
            runner = new JobRunner();
            try {
                runner.run(work, new AgentWorkContext(agentIdentifier(), new BuildRepositoryRemoteAdapter(runner, webSocketSessionHandler), manipulator, getAgentRuntimeInfo(), packageRepositoryExtension, scmExtension, taskExtension, artifactExtension, pluginRequestProcessorRegistry));
            } finally {
                getAgentRuntimeInfo().idle();
                updateServerAgentRuntimeInfo();
            }
            break;
        case build:
            cancelBuild();
            BuildSettings buildSettings = MessageEncoding.decodeData(message.getData(), BuildSettings.class);
            runBuild(buildSettings);
            break;
        case reregister:
            LOG.warn("Reregister: invalidate current agent certificate fingerprint {} and stop websocket webSocketClient.", getAgentRegistry().uuid());
            webSocketSessionHandler.stop();
            sslInfrastructureService.invalidateAgentCertificate();
            break;
        case acknowledge:
            webSocketSessionHandler.acknowledge(message);
            break;
        default:
            throw new RuntimeException("Unknown action: " + message.getAction());
    }
}
Also used : Work(com.thoughtworks.go.remote.work.Work) BuildSettings(com.thoughtworks.go.domain.BuildSettings) AgentWorkContext(com.thoughtworks.go.remote.work.AgentWorkContext)

Aggregations

BuildSettings (com.thoughtworks.go.domain.BuildSettings)1 AgentWorkContext (com.thoughtworks.go.remote.work.AgentWorkContext)1 Work (com.thoughtworks.go.remote.work.Work)1