diff --git a/releaseNote.md b/releaseNote.md index 4c0c189c7..8263ec769 100644 --- a/releaseNote.md +++ b/releaseNote.md @@ -13,6 +13,7 @@ - Better exception handling when runner is configured with invalid Url or token (#1741) - Set user agent for websocket requests (#1791) - Gracefully handle websocket failures (#1789) +- Capture telemetry when git errors on unsafe repository. (#1823) ## Windows x64 We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows. diff --git a/releaseVersion b/releaseVersion index 20a8ae8dd..0eaa716c6 100644 --- a/releaseVersion +++ b/releaseVersion @@ -1 +1 @@ -2.290.0 +2.290.1 diff --git a/src/Runner.Worker/Handlers/OutputManager.cs b/src/Runner.Worker/Handlers/OutputManager.cs index 03bbe789f..a67e35e21 100644 --- a/src/Runner.Worker/Handlers/OutputManager.cs +++ b/src/Runner.Worker/Handlers/OutputManager.cs @@ -151,6 +151,11 @@ namespace GitHub.Runner.Worker.Handlers } } + if (line.Contains("fatal: unsafe repository", StringComparison.OrdinalIgnoreCase)) + { + _executionContext.StepTelemetry.ErrorMessages.Add(line); + } + // Regular output _executionContext.Output(line); } diff --git a/src/Test/L0/Worker/OutputManagerL0.cs b/src/Test/L0/Worker/OutputManagerL0.cs index f02e2bf1e..85045802a 100644 --- a/src/Test/L0/Worker/OutputManagerL0.cs +++ b/src/Test/L0/Worker/OutputManagerL0.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; -using System.Runtime.CompilerServices; using GitHub.Runner.Sdk; using GitHub.Runner.Worker; using GitHub.Runner.Worker.Container; @@ -937,6 +937,19 @@ namespace GitHub.Runner.Common.Tests.Worker } } + [Fact] + [Trait("Level", "L0")] + [Trait("Category", "Worker")] + public void CaptureTelemetryForGitUnsafeRepository() + { + using (Setup()) + using (_outputManager) + { + Process("fatal: unsafe repository ('/github/workspace' is owned by someone else)"); + Assert.Contains("fatal: unsafe repository ('/github/workspace' is owned by someone else)", _executionContext.Object.StepTelemetry.ErrorMessages); + } + } + private TestHostContext Setup( [CallerMemberName] string name = "", IssueMatchersConfig matchers = null, @@ -962,6 +975,8 @@ namespace GitHub.Runner.Common.Tests.Worker Variables = _variables, WriteDebug = true, }); + _executionContext.Setup(x => x.StepTelemetry) + .Returns(new DTWebApi.ActionsStepTelemetry()); _executionContext.Setup(x => x.GetMatchers()) .Returns(matchers?.Matchers ?? new List()); _executionContext.Setup(x => x.Add(It.IsAny())) diff --git a/src/runnerversion b/src/runnerversion index 20a8ae8dd..0eaa716c6 100644 --- a/src/runnerversion +++ b/src/runnerversion @@ -1 +1 @@ -2.290.0 +2.290.1