Skip to content

Commit a06a996

Browse files
committed
refactor(pipelines)!: deprecate pipelines scaffolding
closes criticalmanufacturing#268 criticalmanufacturing#288
1 parent 35f76dc commit a06a996

File tree

77 files changed

+379
-6607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+379
-6607
lines changed

cmf-cli/Commands/init/InitCommand.cs

+13-170
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Cmf.CLI.Constants;
77
using Cmf.CLI.Core.Attributes;
88
using Cmf.CLI.Core.Commands;
9+
using Cmf.CLI.Core.Constants;
910
using Cmf.CLI.Core.Enums;
1011
using Cmf.CLI.Core.Objects;
1112
using Cmf.CLI.Utilities;
@@ -27,7 +28,6 @@ internal class InitArguments
2728
public string version { get; set; }
2829
public IFileInfo config { get; set; }
2930
public IDirectoryInfo deploymentDir { get; set; }
30-
public Uri repositoryUrl { get; set; }
3131
public string BaseVersion { get; set; }
3232
public string DevTasksVersion { get; set; }
3333
public string HTMLStarterVersion { get; set; }
@@ -38,20 +38,10 @@ internal class InitArguments
3838
public IFileInfo infrastructure { get; set; }
3939
public Uri nugetRegistry { get; set; }
4040
public Uri npmRegistry { get; set; }
41-
public Uri azureDevOpsCollectionUrl { get; set; }
42-
public string agentPool { get; set; }
43-
public AgentType? agentType { get; set; }
4441
public IFileInfo ISOLocation { get; set; }
4542
public string nugetRegistryUsername { get; set; }
4643
public string nugetRegistryPassword { get; set; }
47-
public string cmfPipelineRepository { get; set; }
4844
public string cmfCliRepository { get; set; }
49-
public string pipelinesFolder { get; set; }
50-
public string releaseCustomerEnvironment { get; set; }
51-
public string releaseSite { get; set; }
52-
public string releaseDeploymentPackage { get; set; }
53-
public string releaseLicense { get; set; }
54-
public string releaseDeploymentTarget { get; set; }
5545
public RepositoryType repositoryType { get; set; }
5646
// ReSharper restore UnusedAutoPropertyAccessor.Global
5747
// ReSharper restore InconsistentNaming
@@ -117,10 +107,6 @@ public override void Configure(Command cmd)
117107
{ IsRequired = true });
118108

119109
// template-time options. These are all mandatory
120-
cmd.AddOption(new Option<Uri>(
121-
aliases: new[] { "--repositoryUrl" },
122-
description: "Git repository URL"
123-
) { IsRequired = true });
124110
cmd.AddOption(new Option<IDirectoryInfo>(
125111
aliases: new[] { "--deploymentDir" },
126112
parseArgument: argResult => Parse<IDirectoryInfo>(argResult),
@@ -171,18 +157,7 @@ public override void Configure(Command cmd)
171157
aliases: new[] { "--npmRegistry" },
172158
description: "NPM registry that contains the MES packages"
173159
));
174-
cmd.AddOption(new Option<Uri>(
175-
aliases: new[] { "--azureDevOpsCollectionUrl" },
176-
description: "The Azure DevOps collection address"
177-
));
178-
cmd.AddOption(new Option<string>(
179-
aliases: new[] { "--agentPool" },
180-
description: "Azure DevOps agent pool"
181-
));
182-
cmd.AddOption(new Option<AgentType>(
183-
aliases: new[] { "--agentType" },
184-
description: "Type of Azure DevOps agents: Cloud or Hosted"
185-
));
160+
186161
cmd.AddOption(new Option<IFileInfo>(
187162
aliases: new[] { "--ISOLocation" },
188163
parseArgument: argResult => Parse<IFileInfo>(argResult),
@@ -202,63 +177,13 @@ public override void Configure(Command cmd)
202177
description: "NPM registry that contains the CLI",
203178
getDefaultValue: () => new Uri(CliConstants.NpmJsUrl, UriKind.Absolute)
204179
));
205-
cmd.AddOption(new Option<Uri>(
206-
aliases: new[] { "--cmfPipelineRepository" },
207-
description: "NPM registry that contains the CLI Pipeline Plugin"
208-
));
209-
cmd.AddOption(new Option<string>(
210-
aliases: new[] { "--pipelinesFolder" },
211-
getDefaultValue: () => "",
212-
description: "Folder where we should put the pipelines in. Empty means the root folder"
213-
));
214-
215-
// container-specific switches
216-
cmd.AddOption(new Option<string>(
217-
aliases: new[] { "--releaseCustomerEnvironment" },
218-
description: "Customer Environment Name defined in DevOpsCenter"
219-
));
220-
cmd.AddOption(new Option<string>(
221-
aliases: new[] { "--releaseSite" },
222-
description: "Site defined in DevOpsCenter"
223-
));
224-
cmd.AddOption(new Option<string>(
225-
aliases: new[] { "--releaseDeploymentPackage" },
226-
description: "DeploymentPackage defined in DevOpsCenter"
227-
));
228-
cmd.AddOption(new Option<string>(
229-
aliases: new[] { "--releaseLicense" },
230-
description: "License defined in DevOpsCenter"
231-
));
232-
cmd.AddOption(new Option<string>(
233-
aliases: new[] { "--releaseDeploymentTarget" },
234-
description: "DeploymentTarget defined in DevOpsCenter"
235-
));
236-
180+
237181
// Add the handler
238182
cmd.Handler = CommandHandler
239183
.Create((InitArguments args) =>
240184
{
241185
this.Execute(args);
242186
});
243-
// no overload accepts these many arguments...
244-
// .Create<
245-
// IDirectoryInfo, // workingDir
246-
// string, // rootPackageName,
247-
// IFileInfo, // config
248-
// IDirectoryInfo, // deploymentDir
249-
// string, // MESVersion
250-
// string, // DevTasksVersion
251-
// string, // HTMLStarterVersion
252-
// string, // yoGeneratorVersion
253-
// string, // nugetVersion
254-
// string, // testScenariosNugetVersion
255-
// IFileInfo, // infrastructure
256-
// Uri, // nugetRegistry
257-
// Uri, // npmRegistry
258-
// Uri, // universalRegistry
259-
// string, // agentPool
260-
// AgentType? // agentType
261-
// >(this.Execute);
262187
}
263188

264189
/// <summary>
@@ -287,29 +212,9 @@ internal void Execute(InitArguments x)
287212
if (x.deploymentDir != null)
288213
{
289214
args.AddRange(new [] {"--deploymentDir", x.deploymentDir.FullName});
290-
// repositories are sub-folders of deploymentDir
291-
args.AddRange(new [] {"--CIRepo", $"{x.deploymentDir.FullName}\\CIPackages"});
292-
args.AddRange(new [] {"--ADArtifactsRepo", $"{x.deploymentDir.FullName}\\ADArtifacts"});
293-
args.AddRange(new [] {"--RCRepo", $"{x.deploymentDir.FullName}\\ReleaseCandidates"});
294215
args.AddRange(new [] {"--DeliveredRepo", $"{x.deploymentDir.FullName}\\Delivered"});
216+
args.AddRange(new[] { "--CIRepo", $"{x.deploymentDir.FullName}\\CIPackages" });
295217
}
296-
297-
var repoName = x.projectName;
298-
if (x.repositoryUrl != null)
299-
{
300-
args.AddRange(new [] {"--repositoryUrl", x.repositoryUrl.AbsoluteUri});
301-
var match = CliConstants.RepoRegex.Match(x.repositoryUrl.AbsoluteUri);
302-
if ((match?.Success ?? false) && match.Groups.ContainsKey("repo"))
303-
{
304-
repoName = match.Groups["repo"].Value;
305-
}
306-
}
307-
308-
if (repoName != null)
309-
{
310-
args.AddRange(new [] {"--repositoryName", repoName});
311-
}
312-
313218
if (x.BaseVersion != null)
314219
{
315220
args.AddRange(new [] {"--MESVersion", x.BaseVersion});
@@ -329,16 +234,6 @@ internal void Execute(InitArguments x)
329234
args.AddRange(new [] {"--testScenariosNugetVersion", x.testScenariosNugetVersion});
330235
}
331236

332-
if (!string.IsNullOrWhiteSpace(x.pipelinesFolder))
333-
{
334-
var folder = x.pipelinesFolder.Replace("/", "\\");
335-
if (!folder.StartsWith("\\"))
336-
{
337-
folder = "\\" + folder;
338-
}
339-
args.AddRange(new []{"--pipelinesFolder", folder});
340-
}
341-
342237
#region infrastructure
343238

344239
if (x.infrastructure != null)
@@ -349,12 +244,6 @@ internal void Execute(InitArguments x)
349244
{
350245
x.nugetRegistry ??= GenericUtilities.JsonObjectToUri(infraJson["NuGetRegistry"]);
351246
x.npmRegistry ??= GenericUtilities.JsonObjectToUri(infraJson["NPMRegistry"]);
352-
x.azureDevOpsCollectionUrl ??= GenericUtilities.JsonObjectToUri(infraJson["AzureDevopsCollectionURL"]);
353-
x.agentPool ??= infraJson["AgentPool"]?.Value;
354-
if (Enum.TryParse<AgentType>(infraJson["AgentType"]?.Value, out AgentType agentTypeParsed))
355-
{
356-
x.agentType ??= agentTypeParsed;
357-
}
358247
if (!string.IsNullOrEmpty(infraJson["NuGetRegistryUsername"]?.Value))
359248
{
360249
x.nugetRegistryUsername ??= infraJson["NuGetRegistryUsername"]?.Value;
@@ -367,18 +256,16 @@ internal void Execute(InitArguments x)
367256
{
368257
x.cmfCliRepository ??= infraJson["CmfCliRepository"]?.Value;
369258
}
370-
if (!string.IsNullOrEmpty(infraJson["CmfPipelineRepository"]?.Value))
371-
{
372-
x.cmfPipelineRepository ??= infraJson["CmfPipelineRepository"]?.Value;
373-
}
374-
}
375259
}
260+
}
376261

377262
if (x.nugetRegistry == null ||
378263
x.npmRegistry == null ||
379-
x.azureDevOpsCollectionUrl == null ||
380-
x.ISOLocation == null ||
381-
x.agentPool == null)
264+
//x.azureDevOpsCollectionUrl == null ||
265+
x.ISOLocation == null
266+
//||
267+
//x.agentPool == null
268+
)
382269
{
383270
throw new CliException("Missing infrastructure options. Either specify an infrastructure file with [--infrastructure] or specify each infrastructure option separately.");
384271
}
@@ -391,10 +278,6 @@ internal void Execute(InitArguments x)
391278
{
392279
args.AddRange(new [] {"--npmRegistry", x.npmRegistry.AbsoluteUri});
393280
}
394-
if (x.azureDevOpsCollectionUrl != null)
395-
{
396-
args.AddRange(new [] {"--azureDevOpsCollectionUrl", x.azureDevOpsCollectionUrl.AbsoluteUri});
397-
}
398281
if (x.ISOLocation != null)
399282
{
400283
args.AddRange(new [] {"--ISOLocation", x.ISOLocation.FullName});
@@ -410,52 +293,12 @@ internal void Execute(InitArguments x)
410293

411294
args.AddRange(x.cmfCliRepository != null
412295
? new[] { "--cmfCliRepository", x.cmfCliRepository }
413-
: new[] { "--cmfCliRepository", CliConstants.NpmJsUrl });
414-
args.AddRange(x.cmfPipelineRepository != null
415-
? new[] { "--cmfPipelineRepository", x.cmfPipelineRepository }
416-
: new[] { "--cmfPipelineRepository", CliConstants.NpmJsUrl });
296+
: new[] { "--cmfCliRepository", CoreConstants.NpmJsUrl });
417297

418-
if (!string.IsNullOrEmpty(x.agentPool))
419-
{
420-
args.AddRange(new [] {"--agentPool", x.agentPool});
421-
}
422-
args.AddRange(new [] {"--agentType", (x.agentType ??= AgentType.Hosted).ToString()});
423298

424-
425-
#endregion
426-
427-
#region container-specific switches
428-
if (!string.IsNullOrEmpty(x.releaseCustomerEnvironment))
429-
{
430-
args.AddRange(new[] { "--releaseCustomerEnvironment", x.releaseCustomerEnvironment });
431-
}
432-
433-
if (!string.IsNullOrEmpty(x.releaseSite))
434-
{
435-
args.AddRange(new[] { "--releaseSite", x.releaseSite });
436-
}
437-
438-
if (!string.IsNullOrEmpty(x.releaseDeploymentPackage))
439-
{
440-
// we need to escape the @ symbol to avoid that commandline lib parses it as a file
441-
// https://github.com/dotnet/command-line-api/issues/816
442-
x.releaseDeploymentPackage = x.releaseDeploymentPackage.Length > 1 && x.releaseDeploymentPackage[0] == '\\'
443-
? x.releaseDeploymentPackage[1..]
444-
: x.releaseDeploymentPackage;
445-
446-
args.AddRange(new[] { "--releaseDeploymentPackage", $"{x.releaseDeploymentPackage}" });
447-
}
448-
449-
if (!string.IsNullOrEmpty(x.releaseLicense))
450-
{
451-
args.AddRange(new[] { "--releaseLicense", x.releaseLicense });
452-
}
453299

454-
if (!string.IsNullOrEmpty(x.releaseDeploymentTarget))
455-
{
456-
args.AddRange(new[] { "--releaseDeploymentTarget", x.releaseDeploymentTarget });
457-
}
458-
#endregion
300+
301+
#endregion
459302

460303
#region version-specific bits
461304

cmf-cli/Constants/CliConstants.cs

-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ public static class CliConstants
8484
/// </summary>
8585
public const string DefaultStrategyPath = "$.tenants.config.$(tenant).strategies";
8686

87-
/// <summary>
88-
/// regex to determine repository name from the url
89-
/// </summary>
90-
public static readonly Regex RepoRegex = new Regex(@"^(?<proto>\w+):\/\/(?<host>[^\/]+)\/(?<collection>[^/]+)\/(?<project>[^\/]+\/)?_git\/(?<repo>.+)\/?$", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
91-
9287
/// <summary>
9388
/// Default repository type
9489
/// </summary>

cmf-cli/resources/template_feed/init/.project-config.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"BaseLayer": "<%= $CLI_PARAM_BaseLayer %>",
55
"NPMRegistry": "<%= $CLI_PARAM_NPMRegistry %>",
66
"NuGetRegistry": "<%= $CLI_PARAM_NuGetRegistry %>",
7-
"AzureDevopsCollectionURL": "<%= $CLI_PARAM_AzureDevopsCollectionURL %>",
8-
"AgentPool": "<%= $CLI_PARAM_AgentPool %>",
9-
"AgentType": "<%= $CLI_PARAM_AgentType %>",
10-
"RepositoryURL": "<%= $CLI_PARAM_RepositoryURL %>",
117
"EnvironmentName": "<%= $CLI_PARAM_EnvironmentName %>",
128
"DefaultDomain": "<%= $CLI_PARAM_DefaultDomain %>",
139
"RESTPort": "<%= $CLI_PARAM_RESTPort %>",
@@ -34,5 +30,8 @@
3430
"HTMLPort": "<%= $CLI_PARAM_HTMLPort %>",
3531
"GatewayPort": "<%= $CLI_PARAM_GatewayPort %>",
3632
"ReleaseEnvironmentConfig": "<%= $CLI_PARAM_ReleaseEnvironmentConfig %>",
37-
"ISOLocation": "<%= $CLI_PARAM_ISOLocation_JSON %>"
33+
"ISOLocation": "<%= $CLI_PARAM_ISOLocation_JSON %>",
34+
"CmfCliRepository": "<%= $CLI_PARAM_CmfCliRepository %>",
35+
"DeploymentDir": "<%= $CLI_PARAM_DeploymentDir %>",
36+
"DeliveredRepo": "<%= $CLI_PARAM_DeliveredRepo %>"
3837
}

cmf-cli/resources/template_feed/init/Builds/.tasks/approve-release.yml

-54
This file was deleted.

cmf-cli/resources/template_feed/init/Builds/.tasks/clean-agent-directories.yml

-17
This file was deleted.

0 commit comments

Comments
 (0)