diff --git a/source/Calamari.Tests/ArgoCD/Git/AuthenticatingRepositoryFactoryTests.cs b/source/Calamari.Tests/ArgoCD/Git/AuthenticatingRepositoryFactoryTests.cs index 3d4593717..5d559298f 100644 --- a/source/Calamari.Tests/ArgoCD/Git/AuthenticatingRepositoryFactoryTests.cs +++ b/source/Calamari.Tests/ArgoCD/Git/AuthenticatingRepositoryFactoryTests.cs @@ -81,6 +81,8 @@ public void AnonymousCloneWhenNoCredentialsMatch() public class SshUrlTests : AuthenticatingRepositoryFactoryTestBase { [Test] + // SSH not currently functional on Windows + [Category(TestCategory.CompatibleOS.OnlyNixOrMac)] public void SshCredentialBranch_IsSelectedAndDispatchesSshKeyGitConnection() { // Use an ssh:// URL so the new strict validation allows it, and mock the factory @@ -108,6 +110,8 @@ public void HttpsCredentialTakesPriorityOverSshWhenBothMatchAnSshUrl() } [Test] + // SSH not currently functional on Windows + [Category(TestCategory.CompatibleOS.OnlyNixOrMac)] public void KnownHostsFromDtoAreCarriedOntoSshKeyGitConnection() { const string sshUrl = "ssh://git@github.com/org/repo.git"; diff --git a/source/Calamari/ArgoCD/Git/AuthenticatingRepositoryFactory.cs b/source/Calamari/ArgoCD/Git/AuthenticatingRepositoryFactory.cs index d24b3ee2c..0d65231bc 100644 --- a/source/Calamari/ArgoCD/Git/AuthenticatingRepositoryFactory.cs +++ b/source/Calamari/ArgoCD/Git/AuthenticatingRepositoryFactory.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using Calamari.Common.Commands; +using Calamari.Common.Plumbing; using Calamari.Common.Plumbing.Logging; using Octopus.Calamari.Contracts.ArgoCD; @@ -29,6 +31,15 @@ public AuthenticatingRepositoryFactory( public RepositoryWrapper CloneRepository(string requestedUrl, string targetRevision) { var gitCredential = gitCredentials.GetValueOrDefault(requestedUrl); + + if (gitCredential is SshKeyGitCredentialDto && CalamariEnvironment.IsRunningOnWindows) + { + throw new CommandException( + $"Cannot clone '{requestedUrl}' using an SSH key credential: " + + "SSH git credentials are not supported when Calamari is running on Windows. " + + "Supply a username/password credential for this repository, or run the deployment on a Linux worker."); + } + switch (gitCredential) { case GitCredentialDto passwordCredential: @@ -61,4 +72,4 @@ public RepositoryWrapper CloneRepository(string requestedUrl, string targetRevis var anonGitConnection = new HttpsGitConnection(null, null, GitCloneSafeUrl.ConvertToUriString(requestedUrl), GitReference.CreateFromString(targetRevision)); return repositoryFactory.CloneRepository(UniqueRepoNameGenerator.Generate(), anonGitConnection); } -} \ No newline at end of file +}