From d5cddc1f3c593244a2c32e54e924effb0d06c329 Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Wed, 31 Dec 2025 09:17:03 +1100 Subject: [PATCH 1/9] Add more logging around git clone faillure --- source/Calamari/ArgoCD/Git/RepositoryFactory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs index 7f611cc8eb..074217c927 100644 --- a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs +++ b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs @@ -73,7 +73,9 @@ RepositoryWrapper CheckoutGitRepository(IGitConnection gitConnection, string che catch (Exception e) { timedOp.Abandon(e); - throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository?"); + log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}"); + log.VerboseFormat($"Cloning repository failed with error: {e.Message}"); + throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}", e); } } From ec305da66f45ec5fda426db349554d397b7f2b43 Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Wed, 31 Dec 2025 09:22:10 +1100 Subject: [PATCH 2/9] add more logging - exception type --- source/Calamari/ArgoCD/Git/RepositoryFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs index 074217c927..613815f226 100644 --- a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs +++ b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs @@ -74,7 +74,7 @@ RepositoryWrapper CheckoutGitRepository(IGitConnection gitConnection, string che { timedOp.Abandon(e); log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}"); - log.VerboseFormat($"Cloning repository failed with error: {e.Message}"); + log.VerboseFormat($"Cloning repository failed with error: {e.GetType().ToString()} - {e.Message}"); throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}", e); } } From 175d6aa16b460fd794fbaa513ca2ce4dfbe16d5d Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 08:07:11 +1100 Subject: [PATCH 3/9] empty work --- source/Calamari/ArgoCD/Git/RepositoryFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs index 613815f226..1baae4fb49 100644 --- a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs +++ b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs @@ -73,7 +73,7 @@ RepositoryWrapper CheckoutGitRepository(IGitConnection gitConnection, string che catch (Exception e) { timedOp.Abandon(e); - log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}"); + log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}") log.VerboseFormat($"Cloning repository failed with error: {e.GetType().ToString()} - {e.Message}"); throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}", e); } From 9a713e1edf828174b68f1e4a93087b2e7cf80963 Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 08:07:27 +1100 Subject: [PATCH 4/9] revert empty work --- source/Calamari/ArgoCD/Git/RepositoryFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs index 1baae4fb49..613815f226 100644 --- a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs +++ b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs @@ -73,7 +73,7 @@ RepositoryWrapper CheckoutGitRepository(IGitConnection gitConnection, string che catch (Exception e) { timedOp.Abandon(e); - log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}") + log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}"); log.VerboseFormat($"Cloning repository failed with error: {e.GetType().ToString()} - {e.Message}"); throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}", e); } From 1ad771df3b7e33e98c67e355cf568c1d055bf0c5 Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 09:10:54 +1100 Subject: [PATCH 5/9] add variable to allow full stack trace to be dumped to logs --- source/Calamari.Common/CalamariFlavourProgram.cs | 5 ++++- source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs | 6 +++++- source/Calamari.Common/Plumbing/Variables/KnownVariables.cs | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/Calamari.Common/CalamariFlavourProgram.cs b/source/Calamari.Common/CalamariFlavourProgram.cs index dca96f518d..37819ed2eb 100644 --- a/source/Calamari.Common/CalamariFlavourProgram.cs +++ b/source/Calamari.Common/CalamariFlavourProgram.cs @@ -37,6 +37,7 @@ protected CalamariFlavourProgram(ILog log) protected virtual int Run(string[] args) { + bool logCommandExceptionStackTrace = false; try { AppDomainConfiguration.SetDefaultRegexMatchTimeout(); @@ -62,6 +63,8 @@ protected virtual int Run(string[] args) using var container = builder.Build(); container.Resolve().LogVariables(); + var stackTraceVariable = container.Resolve().Get(KnownVariables.Calamari.LogCommandExceptionStackTrace); + logCommandExceptionStackTrace = string.Equals(stackTraceVariable, "true", StringComparison.OrdinalIgnoreCase); #if DEBUG var waitForDebugger = container.Resolve().Get(KnownVariables.Calamari.WaitForDebugger); @@ -82,7 +85,7 @@ protected virtual int Run(string[] args) } catch (Exception ex) { - return ConsoleFormatter.PrintError(log, ex); + return ConsoleFormatter.PrintError(log, ex, logCommandExceptionStackTrace); } } diff --git a/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs b/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs index 90c4068045..5a86daeabd 100644 --- a/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs +++ b/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs @@ -9,11 +9,15 @@ namespace Calamari.Common.Plumbing.Logging { public class ConsoleFormatter { - public static int PrintError(ILog log, Exception ex) + public static int PrintError(ILog log, Exception ex, bool logCommandExceptionStackTrace = false) { if (ex is CommandException) { log.Error(ex.Message); + if (logCommandExceptionStackTrace) + { + log.Verbose(ex.ToString()); + } return ExitStatus.CommandExceptionError; } diff --git a/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs b/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs index d4cd91b2af..a833ed27c0 100644 --- a/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs +++ b/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs @@ -47,6 +47,7 @@ public static class Calamari public const string EnablePackageRetention = "Octopus.Calamari.EnablePackageRetention"; public const string PackageRetentionJournalPath = "env:CalamariPackageRetentionJournalPath"; public const string PackageRetentionLockExpiration = "Octopus.Calamari.PackageRetentionLockExpiration"; + public const string LogCommandExceptionStackTrace = "Octopus.Calamari.LogCommandExceptionStackTrace"; } public static class Release From 89989fdf995c306040c0dcb20e633af03f47e7e6 Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 09:57:42 +1100 Subject: [PATCH 6/9] fix task log --- .../ArgoCD/Conventions/ArgoCDTaskLogExtensionMethods.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Calamari/ArgoCD/Conventions/ArgoCDTaskLogExtensionMethods.cs b/source/Calamari/ArgoCD/Conventions/ArgoCDTaskLogExtensionMethods.cs index 07baaf0f6a..3c758c89a4 100644 --- a/source/Calamari/ArgoCD/Conventions/ArgoCDTaskLogExtensionMethods.cs +++ b/source/Calamari/ArgoCD/Conventions/ArgoCDTaskLogExtensionMethods.cs @@ -36,7 +36,7 @@ static void LogMissingAnnotationsWarning(this ILog log, (ProjectSlug Project, En { log.WarnFormat(" - {0}: {1}", ArgoCDConstants.Annotations.OctopusTenantAnnotationKey("".ToApplicationSourceName()), deploymentScope.Tenant); } - log.WarnFormat("Annotation creation documentation can be found {0}.", log.FormatShortLink("argo-cd-scoping-annotations", "here")); + log.WarnFormat("Annotation creation documentation can be found {0}.", log.FormatShortLink("argo-cd-annotations-docs", "here")); } public static void LogApplicationCounts(this ILog log, (ProjectSlug Project, EnvironmentSlug Environment, TenantSlug? Tenant) deploymentScope, ArgoCDApplicationDto[] applications) From 8608ddac0d115df828bb88bd5f27b315ea34fcec Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 11:10:48 +1100 Subject: [PATCH 7/9] minimise change --- source/Calamari/ArgoCD/Git/RepositoryFactory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs index 613815f226..bc416e0f7f 100644 --- a/source/Calamari/ArgoCD/Git/RepositoryFactory.cs +++ b/source/Calamari/ArgoCD/Git/RepositoryFactory.cs @@ -73,9 +73,9 @@ RepositoryWrapper CheckoutGitRepository(IGitConnection gitConnection, string che catch (Exception e) { timedOp.Abandon(e); - log.Error($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}"); - log.VerboseFormat($"Cloning repository failed with error: {e.GetType().ToString()} - {e.Message}"); - throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}", e); + log.Error("Cloning repository failed"); + log.Verbose(e.PrettyPrint()); + throw new CommandException($"Failed to clone Git repository at {gitConnection.Url}. Are you sure this is a Git repository? {e.Message}", e); } } From f5c7adc9a35927c0131a24475f7613880e5c068b Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 11:11:37 +1100 Subject: [PATCH 8/9] remove cruft --- source/Calamari.Common/CalamariFlavourProgram.cs | 5 +---- source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs | 6 +----- source/Calamari.Common/Plumbing/Variables/KnownVariables.cs | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/source/Calamari.Common/CalamariFlavourProgram.cs b/source/Calamari.Common/CalamariFlavourProgram.cs index 37819ed2eb..dca96f518d 100644 --- a/source/Calamari.Common/CalamariFlavourProgram.cs +++ b/source/Calamari.Common/CalamariFlavourProgram.cs @@ -37,7 +37,6 @@ protected CalamariFlavourProgram(ILog log) protected virtual int Run(string[] args) { - bool logCommandExceptionStackTrace = false; try { AppDomainConfiguration.SetDefaultRegexMatchTimeout(); @@ -63,8 +62,6 @@ protected virtual int Run(string[] args) using var container = builder.Build(); container.Resolve().LogVariables(); - var stackTraceVariable = container.Resolve().Get(KnownVariables.Calamari.LogCommandExceptionStackTrace); - logCommandExceptionStackTrace = string.Equals(stackTraceVariable, "true", StringComparison.OrdinalIgnoreCase); #if DEBUG var waitForDebugger = container.Resolve().Get(KnownVariables.Calamari.WaitForDebugger); @@ -85,7 +82,7 @@ protected virtual int Run(string[] args) } catch (Exception ex) { - return ConsoleFormatter.PrintError(log, ex, logCommandExceptionStackTrace); + return ConsoleFormatter.PrintError(log, ex); } } diff --git a/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs b/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs index 5a86daeabd..90c4068045 100644 --- a/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs +++ b/source/Calamari.Common/Plumbing/Logging/ConsoleFormatter.cs @@ -9,15 +9,11 @@ namespace Calamari.Common.Plumbing.Logging { public class ConsoleFormatter { - public static int PrintError(ILog log, Exception ex, bool logCommandExceptionStackTrace = false) + public static int PrintError(ILog log, Exception ex) { if (ex is CommandException) { log.Error(ex.Message); - if (logCommandExceptionStackTrace) - { - log.Verbose(ex.ToString()); - } return ExitStatus.CommandExceptionError; } diff --git a/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs b/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs index a833ed27c0..d4cd91b2af 100644 --- a/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs +++ b/source/Calamari.Common/Plumbing/Variables/KnownVariables.cs @@ -47,7 +47,6 @@ public static class Calamari public const string EnablePackageRetention = "Octopus.Calamari.EnablePackageRetention"; public const string PackageRetentionJournalPath = "env:CalamariPackageRetentionJournalPath"; public const string PackageRetentionLockExpiration = "Octopus.Calamari.PackageRetentionLockExpiration"; - public const string LogCommandExceptionStackTrace = "Octopus.Calamari.LogCommandExceptionStackTrace"; } public static class Release From ca014c414c3eb8f812fc894da336b66c0db41d07 Mon Sep 17 00:00:00 2001 From: Trent Mohay Date: Mon, 5 Jan 2026 13:13:23 +1100 Subject: [PATCH 9/9] hack the working directory for good or evil --- build/Build.TestCalamariFlavourProject.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/build/Build.TestCalamariFlavourProject.cs b/build/Build.TestCalamariFlavourProject.cs index edf8bd5e3f..1837832f35 100644 --- a/build/Build.TestCalamariFlavourProject.cs +++ b/build/Build.TestCalamariFlavourProject.cs @@ -40,6 +40,7 @@ partial class Build DotNetTasks.DotNetTest(settings => settings .SetProjectFile($"CalamariTests/{testProject}.dll") + .SetProcessWorkingDirectory("CalamariTests") .SetFilter(CalamariFlavourTestCaseFilter) .SetLoggers("trx") .SetProcessExitHandler(