public async Task BeginAsync() { try { await messageClient.ConnectAsync(definition.TcpHost, definition.TcpPort); Log.Info($"Connected to Agent '{definition.Name}'."); } catch (Exception error) { Log.Error($"Failed to connect to Agent '{definition.Name}'!", error); throw new ApplicationException($"Failed to connect to Agent '{definition.Name}'! {error.Message}"); } var message = new BuildSessionBeginRequest { ServerSessionId = context.ServerSessionId, Project = context.Project, AssemblyFile = context.AssemblyFilename, PreBuild = context.PreBuild, GitRefspec = context.GitRefspec, BuildNumber = context.BuildNumber, }; try { var response = await messageClient.Send(message) .GetResponseAsync <BuildSessionBeginResponse>(); AgentSessionId = response.SessionId; } catch (Exception error) { throw new ApplicationException($"Failed to start Agent Session! {error.Message}"); } BuildTasks.Start(); }
protected override async Task OnBeginSession() { var message = new BuildSessionBeginRequest { ServerSessionId = session.SessionId, SessionClientId = SessionClientId, Project = session.Project, AssemblyFile = session.AssemblyFilename, PreBuild = session.PreBuild, GitRefspec = session.GitRefspec, BuildNumber = session.BuildNumber, Variables = session.Variables, Commit = session.Commit, }; var response = await MessageClient.Send(message) .GetResponseAsync <BuildSessionBeginResponse>(); AgentSessionId = response.AgentSessionId; }