Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipelines cleanup and new CD-Containers #93

Merged
merged 5 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,7 @@ dist/
launchSettings.json

!**/Commands/publish
*.orig
*.orig

# xyz.local-history vscode extension
.history/**
85 changes: 69 additions & 16 deletions cmf-cli/Commands/init/InitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace Cmf.Common.Cli.Commands
public enum AgentType
{
/// <summary>
/// Cloud agents
/// Cloud agents
/// </summary>
Cloud,
/// <summary>
/// Self-host agents
/// </summary>
Hosted
}

// this is public because Execute is public by convention but never invoked externally
// so this class mirrors the command internal structure and is never used outside
// ReSharper disable once ClassNeverInstantiated.Global
Expand Down Expand Up @@ -56,6 +56,11 @@ internal class InitArguments
public string nugetRegistryPassword { get; set; }
public string cmfPipelineRepository { get; set; }
public string cmfCliRepository { get; set; }
public string releaseCustomerEnvironment { get; set; }
public string releaseSite { get; set; }
public string releaseDeploymentPackage { get; set; }
public string releaseLicense { get; set; }
public string releaseDeploymentTarget { get; set; }
// ReSharper restore UnusedAutoPropertyAccessor.Global
// ReSharper restore InconsistentNaming
}
Expand Down Expand Up @@ -149,7 +154,7 @@ public override void Configure(Command cmd)
aliases: new[] { "--testScenariosNugetVersion" },
description: "Test Scenarios Nuget Version"
));

// infra options
cmd.AddOption(new Option<IFileInfo>(
aliases: new[] { "--infra", "--infrastructure" },
Expand Down Expand Up @@ -191,6 +196,26 @@ public override void Configure(Command cmd)
aliases: new[] { "--nugetRegistryPassword" },
description: "NuGet registry password"
));
cmd.AddOption(new Option<string>(
aliases: new[] { "--releaseCustomerEnvironment" },
description: "Customer Environment Name defined in DevOpsCenter"
));
cmd.AddOption(new Option<string>(
aliases: new[] { "--releaseSite" },
description: "Site defined in DevOpsCenter"
));
cmd.AddOption(new Option<string>(
aliases: new[] { "--releaseDeploymentPackage" },
description: "DeploymentPackage defined in DevOpsCenter"
));
cmd.AddOption(new Option<string>(
aliases: new[] { "--releaseLicense" },
description: "License defined in DevOpsCenter"
));
cmd.AddOption(new Option<string>(
aliases: new[] { "--releaseDeploymentTarget" },
description: "DeploymentTarget defined in DevOpsCenter"
));

// Add the handler
cmd.Handler = CommandHandler
Expand Down Expand Up @@ -228,7 +253,7 @@ internal void Execute(InitArguments x)
{
// engine options
"--output", x.workingDir.FullName,

// template symbols
"--customPackageName", x.rootPackageName,
"--projectName", x.projectName
Expand All @@ -238,7 +263,7 @@ internal void Execute(InitArguments x)
{
args.AddRange(new [] {"--packageVersion", x.version});
}

if (x.deploymentDir != null)
{
args.AddRange(new [] {"--deploymentDir", x.deploymentDir.FullName});
Expand All @@ -248,12 +273,12 @@ internal void Execute(InitArguments x)
args.AddRange(new [] {"--RCRepo", $"{x.deploymentDir.FullName}\\ReleaseCandidates"});
args.AddRange(new [] {"--DeliveredRepo", $"{x.deploymentDir.FullName}\\Delivered"});
}

if (x.repositoryUrl != null)
{
args.AddRange(new [] {"--repositoryUrl", x.repositoryUrl.AbsoluteUri});
}

if (x.MESVersion != null)
{
args.AddRange(new [] {"--MESVersion", x.MESVersion});
Expand All @@ -278,9 +303,9 @@ internal void Execute(InitArguments x)
{
args.AddRange(new [] {"--testScenariosNugetVersion", x.testScenariosNugetVersion});
}


#region infrastructure

if (x.infrastructure != null)
{
var infraTxt = this.fileSystem.File.ReadAllText(x.infrastructure.FullName);
Expand All @@ -291,13 +316,9 @@ internal void Execute(InitArguments x)
x.npmRegistry ??= GenericUtilities.JsonObjectToUri(infraJson["NPMRegistry"]);
x.azureDevOpsCollectionUrl ??= GenericUtilities.JsonObjectToUri(infraJson["AzureDevopsCollectionURL"]);
x.agentPool ??= infraJson["AgentPool"]?.Value;
if (infraJson["ISOLocation"]?.Value != null)
{
x.ISOLocation ??= this.fileSystem.FileInfo.FromFileName(infraJson["ISOLocation"]?.Value);
}
if (Enum.TryParse<AgentType>(infraJson["AgentType"]?.Value, out AgentType agentTypeParsed))
{
x.agentType ??= agentTypeParsed;
x.agentType ??= agentTypeParsed;
}
if (!string.IsNullOrEmpty(infraJson["NuGetRegistryUsername"]?.Value))
{
Expand Down Expand Up @@ -325,7 +346,7 @@ internal void Execute(InitArguments x)
}
}
}

if (x.nugetRegistry != null)
{
args.AddRange(new [] {"--nugetRegistry", x.nugetRegistry.AbsoluteUri});
Expand Down Expand Up @@ -363,18 +384,50 @@ internal void Execute(InitArguments x)
args.AddRange(new [] {"--agentPool", x.agentPool});
}
args.AddRange(new [] {"--agentType", (x.agentType ??= AgentType.Hosted).ToString()});

if (!string.IsNullOrEmpty(x.releaseCustomerEnvironment))
{
args.AddRange(new[] { "--releaseCustomerEnvironment", x.releaseCustomerEnvironment });
}

if (!string.IsNullOrEmpty(x.releaseSite))
{
args.AddRange(new[] { "--releaseSite", x.releaseSite });
}

if (!string.IsNullOrEmpty(x.releaseDeploymentPackage))
{
// we need to escape the @ symbol to avoid that commandline lib parses it as a file
// https://github.com/dotnet/command-line-api/issues/816
x.releaseDeploymentPackage = x.releaseDeploymentPackage.Length > 1 && x.releaseDeploymentPackage[0] == '\\'
? x.releaseDeploymentPackage[1..]
: x.releaseDeploymentPackage;

args.AddRange(new[] { "--releaseDeploymentPackage", $"{x.releaseDeploymentPackage}" });
}

if (!string.IsNullOrEmpty(x.releaseLicense))
{
args.AddRange(new[] { "--releaseLicense", x.releaseLicense });
}

if (!string.IsNullOrEmpty(x.releaseDeploymentTarget))
{
args.AddRange(new[] { "--releaseDeploymentTarget", x.releaseDeploymentTarget });
}

#endregion

if (x.config != null)
{
args.AddRange(ParseConfigFile(x.config));
}

this.RunCommand(args);

if (x.config != null)
{
var envConfigPath = this.fileSystem.Path.Join(FileSystemUtilities.GetProjectRoot(this.fileSystem).FullName, "EnvironmentConfigs");
var envConfigPath = this.fileSystem.Path.Join(FileSystemUtilities.GetProjectRoot(this.fileSystem, throwException: true).FullName, "EnvironmentConfigs");
x.config.CopyTo(this.fileSystem.Path.Join(envConfigPath, x.config.Name));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,36 @@
"datatype": "string",
"defaultValue": "",
"replaces": "<%= $CLI_PARAM_ReleaseEnvironmentConfig %>"
},
"releaseCustomerEnvironment": {
"type": "parameter",
"datatype": "string",
"defaultValue": "",
"replaces": "<%= $CLI_PARAM_ReleaseCustomerEnvironment %>"
},
"releaseSite": {
"type": "parameter",
"datatype": "string",
"defaultValue": "",
"replaces": "<%= $CLI_PARAM_ReleaseSite %>"
},
"releaseDeploymentPackage": {
"type": "parameter",
"datatype": "string",
"defaultValue": "",
"replaces": "<%= $CLI_PARAM_ReleaseDeploymentPackage %>"
},
"releaseLicense": {
"type": "parameter",
"datatype": "string",
"defaultValue": "",
"replaces": "<%= $CLI_PARAM_ReleaseLicense %>"
},
"releaseDeploymentTarget": {
"type": "parameter",
"datatype": "string",
"defaultValue": "",
"replaces": "<%= $CLI_PARAM_ReleaseDeploymentTarget %>"
}
},
"forms": {
Expand Down
92 changes: 92 additions & 0 deletions cmf-cli/resources/template_feed/init/Builds/CD-Containers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"options": [
{
"enabled": false,
"definition": {
"id": "5d58cc01-7c75-450c-be18-a388ddb129ec"
},
"inputs": {
"branchFilters": "[\"+refs/heads/*\"]",
"additionalFields": "{}"
}
},
{
"enabled": false,
"definition": {
"id": "a9db38f9-9fdc-478c-b0f9-464221e58316"
},
"inputs": {
"workItemType": "Bug",
"assignToRequestor": "true",
"additionalFields": "{}"
}
},
{
"enabled": false,
"definition": {
"id": "57578776-4c22-4526-aeb0-86b6da17ee9c"
},
"inputs": {}
}
],
"triggers": [
{
"branchFilters": [],
"pathFilters": [],
"settingsSourceType": 2,
"batchChanges": false,
"maxConcurrentBuildsPerBranch": 1,
"triggerType": 2
}
],
"properties": {},
"tags": [],
"jobAuthorizationScope": 1,
"jobTimeoutInMinutes": 60,
"jobCancelTimeoutInMinutes": 5,
"process": {
"yamlFilename": "/Builds/CD-Containers.yml",
"type": 2
},
"repository": {
"properties": {
"cloneUrl": "<%= $CLI_PARAM_RepositoryURL %>",
"fullName": "<%= $CLI_PARAM_ProjectName %>",
"defaultBranch": "refs/heads/development",
"isFork": "False",
"safeRepository": "e8c523b0-e52d-4698-ac78-a79f6e0487a3",
"reportBuildStatus": "true",
"cleanOptions": "3",
"fetchDepth": "0",
"gitLfsSupport": "false",
"skipSyncSource": "false",
"checkoutNestedSubmodules": "false",
"labelSources": "0",
"labelSourcesFormat": "$(build.buildNumber)"
},
"type": "TfsGit",
"name": "<%= $CLI_PARAM_ProjectName %>",
"url": "<%= $CLI_PARAM_RepositoryURL %>",
"defaultBranch": "refs/heads/development",
"clean": "true",
"checkoutSubmodules": false
},
"quality": 1,
"drafts": [],
"queue": {
"name": "<%= $CLI_PARAM_AgentPool %>",
"pool": {
"id": 2,
"name": "<%= $CLI_PARAM_AgentPool %>"
}
},
"id": 1063,
"name": "CD-Containers",
"url": "<%= $CLI_PARAM_AzureDevopsCollectionURL %>/d659bbbd-b8f0-4d06-b2a9-1a161455189f/_apis/build/Definitions/1063?revision=14",
"uri": "vstfs:///Build/Definition/1063",
"path": "\\Releases",
"type": 2,
"queueStatus": 2,
"revision": 14,
"createdDate": "2021-02-19T12:33:15.143Z"
}
Loading