Skip to content

Commit

Permalink
Added repository name and workflow file name to console output (#1761)
Browse files Browse the repository at this point in the history
* Adding repo name and workflow file to console output

* Add guard for empty workflow file name
  • Loading branch information
ruvceskistefan authored Mar 17, 2022
1 parent ddc700e commit 98aa9c1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Runner.Listener/JobDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ private async Task RunAsync(Pipelines.AgentJobRequestMessage message, string orc
}

var term = HostContext.GetService<ITerminal>();
term.WriteLine($"{DateTime.UtcNow:u}: Running job: {message.JobDisplayName}");

string workflowName = message.Variables["system.workflowFilePath"].Value.Split('/').LastOrDefault();
string additionalInfo = string.IsNullOrEmpty(workflowName) ? $"(in repository \"{_runnerSettings.RepoOrOrgName}\")" : $"(workflow \"{workflowName}\" in repository \"{_runnerSettings.RepoOrOrgName}\")";
term.WriteLine($"{DateTime.UtcNow:u}: Running job: \"{message.JobDisplayName}\" {additionalInfo}");

// first job request renew succeed.
TaskCompletionSource<int> firstJobRequestRenewed = new TaskCompletionSource<int>();
Expand Down Expand Up @@ -531,7 +534,7 @@ await processChannel.SendAsync(

TaskResult result = TaskResultUtil.TranslateFromReturnCode(returnCode);
Trace.Info($"finish job request for job {message.JobId} with result: {result}");
term.WriteLine($"{DateTime.UtcNow:u}: Job {message.JobDisplayName} completed with result: {result}");
term.WriteLine($"{DateTime.UtcNow:u}: Job \"{message.JobDisplayName}\" {additionalInfo} completed with result: {result}");

Trace.Info($"Stop renew job request for job {message.JobId}.");
// stop renew lock
Expand Down Expand Up @@ -627,7 +630,7 @@ await processChannel.SendAsync(
}

Trace.Info($"finish job request for job {message.JobId} with result: {resultOnAbandonOrCancel}");
term.WriteLine($"{DateTime.UtcNow:u}: Job {message.JobDisplayName} completed with result: {resultOnAbandonOrCancel}");
term.WriteLine($"{DateTime.UtcNow:u}: Job \"{message.JobDisplayName}\" {additionalInfo} completed with result: {resultOnAbandonOrCancel}");
// complete job request with cancel result, stop renew lock, job has finished.

Trace.Info($"Stop renew job request for job {message.JobId}.");
Expand Down

0 comments on commit 98aa9c1

Please sign in to comment.