From 0b691536d496d88277c660846e23c8cbec354155 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Tue, 23 Aug 2022 15:03:43 -0700 Subject: [PATCH] Add setup script to seed azdo project --- .../pipelines/classic/valet-classic1.json | 452 +++++++++--------- .../pipelines/classic/valet-classic2.json | 452 +++++++++--------- ...l => valet-custom-transformer-example.yml} | 0 azure_devops/bootstrap/setup | 178 +++++++ azure_devops/valet-migrate-custom-lab.md | 4 +- 5 files changed, 632 insertions(+), 454 deletions(-) rename azure_devops/bootstrap/pipelines/yml/{valet-mapper-example.yml => valet-custom-transformer-example.yml} (100%) create mode 100755 azure_devops/bootstrap/setup diff --git a/azure_devops/bootstrap/pipelines/classic/valet-classic1.json b/azure_devops/bootstrap/pipelines/classic/valet-classic1.json index 1ade862..43052b4 100644 --- a/azure_devops/bootstrap/pipelines/classic/valet-classic1.json +++ b/azure_devops/bootstrap/pipelines/classic/valet-classic1.json @@ -1,243 +1,243 @@ { - "options": [ - { + "options": [ + { + "enabled": true, + "definition": { + "id": "5d58cc01-7c75-450c-be18-a388ddb129ec" + }, + "inputs": { + "branchFilters": "[\"+refs/heads/*\"]", + "additionalFields": "{}" + } + }, + { + "enabled": false, + "definition": { + "id": "a9db38f9-9fdc-478c-b0f9-464221e58316" + }, + "inputs": { + "workItemType": "Task", + "assignToRequestor": "true", + "additionalFields": "{}" + } + } + ], + "variables": { + "BuildConfiguration": { + "value": "release", + "allowOverride": true + }, + "BuildPlatform": { + "value": "any cpu", + "allowOverride": true + }, + "system.debug": { + "value": "false", + "allowOverride": true + } + }, + "properties": {}, + "tags": [], + "_links": [], + "buildNumberFormat": "$(date:yyyyMMdd)$(rev:.r)", + "jobAuthorizationScope": 1, + "jobTimeoutInMinutes": 60, + "jobCancelTimeoutInMinutes": 5, + "process": { + "phases": [ + { + "steps": [ + { + "environment": {}, "enabled": true, - "definition": { - "id": "5d58cc01-7c75-450c-be18-a388ddb129ec" + "continueOnError": false, + "alwaysRun": false, + "displayName": "Use NuGet 4.4.1", + "timeoutInMinutes": 0, + "retryCountOnTaskFailure": 0, + "condition": "succeeded()", + "task": { + "id": "2c65196a-54fd-4a02-9be8-d9d1837b7c5d", + "versionSpec": "0.*", + "definitionType": "task" }, "inputs": { - "branchFilters": "[\"+refs/heads/*\"]", - "additionalFields": "{}" + "versionSpec": "4.4.1", + "checkLatest": "false" } - }, - { - "enabled": false, - "definition": { - "id": "a9db38f9-9fdc-478c-b0f9-464221e58316" + }, + { + "environment": {}, + "enabled": true, + "continueOnError": false, + "alwaysRun": false, + "displayName": "NuGet restore", + "timeoutInMinutes": 0, + "retryCountOnTaskFailure": 0, + "condition": "succeeded()", + "task": { + "id": "333b11bd-d341-40d9-afcf-b32d5ce6f23b", + "versionSpec": "2.*", + "definitionType": "task" }, "inputs": { - "workItemType": "Task", - "assignToRequestor": "true", - "additionalFields": "{}" + "command": "restore", + "solution": "$(Parameters.solution)", + "selectOrConfig": "select", + "feedRestore": "", + "includeNuGetOrg": "true", + "nugetConfigPath": "", + "externalEndpoints": "", + "noCache": "false", + "disableParallelProcessing": "false", + "packagesDirectory": "", + "verbosityRestore": "Detailed", + "searchPatternPush": "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg", + "nuGetFeedType": "internal", + "feedPublish": "", + "publishPackageMetadata": "true", + "allowPackageConflicts": "false", + "externalEndpoint": "", + "verbosityPush": "Detailed", + "searchPatternPack": "**/*.csproj", + "configurationToPack": "$(BuildConfiguration)", + "outputDir": "$(Build.ArtifactStagingDirectory)", + "versioningScheme": "off", + "includeReferencedProjects": "false", + "versionEnvVar": "", + "requestedMajorVersion": "1", + "requestedMinorVersion": "0", + "requestedPatchVersion": "0", + "packTimezone": "utc", + "includeSymbols": "false", + "toolPackage": "false", + "buildProperties": "", + "basePath": "", + "verbosityPack": "Detailed", + "arguments": "" } - } - ], - "variables": { - "BuildConfiguration": { - "value": "release", - "allowOverride": true - }, - "BuildPlatform": { - "value": "any cpu", - "allowOverride": true - }, - "system.debug": { - "value": "false", - "allowOverride": true - } - }, - "properties": {}, - "tags": [], - "_links": [], - "buildNumberFormat": "$(date:yyyyMMdd)$(rev:.r)", - "jobAuthorizationScope": 1, - "jobTimeoutInMinutes": 60, - "jobCancelTimeoutInMinutes": 5, - "process": { - "phases": [ - { - "steps": [ - { - "environment": {}, - "enabled": true, - "continueOnError": false, - "alwaysRun": false, - "displayName": "Use NuGet 4.4.1", - "timeoutInMinutes": 0, - "retryCountOnTaskFailure": 0, - "condition": "succeeded()", - "task": { - "id": "2c65196a-54fd-4a02-9be8-d9d1837b7c5d", - "versionSpec": "0.*", - "definitionType": "task" - }, - "inputs": { - "versionSpec": "4.4.1", - "checkLatest": "false" - } - }, - { - "environment": {}, - "enabled": true, - "continueOnError": false, - "alwaysRun": false, - "displayName": "NuGet restore", - "timeoutInMinutes": 0, - "retryCountOnTaskFailure": 0, - "condition": "succeeded()", - "task": { - "id": "333b11bd-d341-40d9-afcf-b32d5ce6f23b", - "versionSpec": "2.*", - "definitionType": "task" - }, - "inputs": { - "command": "restore", - "solution": "$(Parameters.solution)", - "selectOrConfig": "select", - "feedRestore": "", - "includeNuGetOrg": "true", - "nugetConfigPath": "", - "externalEndpoints": "", - "noCache": "false", - "disableParallelProcessing": "false", - "packagesDirectory": "", - "verbosityRestore": "Detailed", - "searchPatternPush": "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg", - "nuGetFeedType": "internal", - "feedPublish": "", - "publishPackageMetadata": "true", - "allowPackageConflicts": "false", - "externalEndpoint": "", - "verbosityPush": "Detailed", - "searchPatternPack": "**/*.csproj", - "configurationToPack": "$(BuildConfiguration)", - "outputDir": "$(Build.ArtifactStagingDirectory)", - "versioningScheme": "off", - "includeReferencedProjects": "false", - "versionEnvVar": "", - "requestedMajorVersion": "1", - "requestedMinorVersion": "0", - "requestedPatchVersion": "0", - "packTimezone": "utc", - "includeSymbols": "false", - "toolPackage": "false", - "buildProperties": "", - "basePath": "", - "verbosityPack": "Detailed", - "arguments": "" - } - }, - { - "environment": {}, - "enabled": true, - "continueOnError": false, - "alwaysRun": false, - "displayName": "PowerShell Script", - "timeoutInMinutes": 0, - "retryCountOnTaskFailure": 0, - "condition": "succeeded()", - "task": { - "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1", - "versionSpec": "2.*", - "definitionType": "task" - }, - "inputs": { - "targetType": "inline", - "filePath": "", - "arguments": "", - "script": "# Write your PowerShell commands here.\n\nWrite-Host \"Hello World\"\n", - "errorActionPreference": "stop", - "warningPreference": "default", - "informationPreference": "default", - "verbosePreference": "default", - "debugPreference": "default", - "failOnStderr": "false", - "showWarnings": "false", - "ignoreLASTEXITCODE": "false", - "pwsh": "false", - "workingDirectory": "", - "runScriptInSeparateScope": "false" - } - } - ], - "name": "Agent job 1", - "refName": "Job_1", - "condition": "succeeded()", - "target": { - "executionOptions": { - "type": 0 - }, - "allowScriptsAuthAccessOption": false, - "type": 1 - }, - "jobAuthorizationScope": 1 + }, + { + "environment": {}, + "enabled": true, + "continueOnError": false, + "alwaysRun": false, + "displayName": "PowerShell Script", + "timeoutInMinutes": 0, + "retryCountOnTaskFailure": 0, + "condition": "succeeded()", + "task": { + "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1", + "versionSpec": "2.*", + "definitionType": "task" + }, + "inputs": { + "targetType": "inline", + "filePath": "", + "arguments": "", + "script": "# Write your PowerShell commands here.\n\nWrite-Host \"Hello World\"\n", + "errorActionPreference": "stop", + "warningPreference": "default", + "informationPreference": "default", + "verbosePreference": "default", + "debugPreference": "default", + "failOnStderr": "false", + "showWarnings": "false", + "ignoreLASTEXITCODE": "false", + "pwsh": "false", + "workingDirectory": "", + "runScriptInSeparateScope": "false" } + } ], + "name": "Agent job 1", + "refName": "Job_1", + "condition": "succeeded()", "target": { - "agentSpecification": { - "identifier": "windows-latest" - } + "executionOptions": { + "type": 0 + }, + "allowScriptsAuthAccessOption": false, + "type": 1 }, - "type": 1 + "jobAuthorizationScope": 1 + } + ], + "target": { + "agentSpecification": { + "identifier": "windows-latest" + } }, - "repository": { - "properties": { - "cleanOptions": "0", - "labelSources": "0", - "labelSourcesFormat": "$(build.buildNumber)", - "reportBuildStatus": "true", - "gitLfsSupport": "false", - "skipSyncSource": "false", - "checkoutNestedSubmodules": "false", - "fetchDepth": "0" - }, - "id": "", - "type": "TfsGit", - "name": "REPOTOREPLACE", - "url": "", - "defaultBranch": "refs/heads/main", - "clean": "false", - "checkoutSubmodules": false + "type": 1 + }, + "repository": { + "properties": { + "cleanOptions": "0", + "labelSources": "0", + "labelSourcesFormat": "$(build.buildNumber)", + "reportBuildStatus": "true", + "gitLfsSupport": "false", + "skipSyncSource": "false", + "checkoutNestedSubmodules": "false", + "fetchDepth": "0" }, - "processParameters": { - "inputs": [ - { - "aliases": [], - "options": {}, - "properties": {}, - "name": "solution", - "label": "Solution", - "defaultValue": "**\\*.sln", - "required": true, - "type": "filePath", - "helpMarkDown": "The path to the Visual Studio solution file or NuGet packages.config. Wildcards can be used. For example, `**\\\\*.sln` for all sln files in all sub folders." - } - ] + "id": "", + "type": "TfsGit", + "name": "REPOTOREPLACE", + "url": "", + "defaultBranch": "refs/heads/main", + "clean": "false", + "checkoutSubmodules": false + }, + "processParameters": { + "inputs": [ + { + "aliases": [], + "options": {}, + "properties": {}, + "name": "solution", + "label": "Solution", + "defaultValue": "**\\*.sln", + "required": true, + "type": "filePath", + "helpMarkDown": "The path to the Visual Studio solution file or NuGet packages.config. Wildcards can be used. For example, `**\\\\*.sln` for all sln files in all sub folders." + } + ] + }, + "quality": 1, + "authoredBy": { + "displayName": "David Kalmin", + "url": "https://spsprodcus5.vssps.visualstudio.com/A8ceff4ff-6429-4de3-9c39-fd7f0b1fb05a/_apis/Identities/a886d3a4-5700-6920-a3e4-6dadf46e7614", + "_links": { + "avatar": { + "href": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" + } }, - "quality": 1, - "authoredBy": { - "displayName": "David Kalmin", - "url": "https://spsprodcus5.vssps.visualstudio.com/A8ceff4ff-6429-4de3-9c39-fd7f0b1fb05a/_apis/Identities/a886d3a4-5700-6920-a3e4-6dadf46e7614", - "_links": { - "avatar": { - "href": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" - } - }, - "id": "a886d3a4-5700-6920-a3e4-6dadf46e7614", - "uniqueName": "davidkalmin@microsoft.com", - "imageUrl": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0", - "descriptor": "aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" + "id": "a886d3a4-5700-6920-a3e4-6dadf46e7614", + "uniqueName": "davidkalmin@microsoft.com", + "imageUrl": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0", + "descriptor": "aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" + }, + "drafts": [], + "queue": { + "_links": { + "self": { + "href": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126" + } }, - "drafts": [], - "queue": { - "_links": { - "self": { - "href": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126" - } - }, - "name": "Azure Pipelines", - "url": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126", - "pool": { - "name": "Azure Pipelines", - "isHosted": true - } - }, - "id": 10, - "name": "valet-classic-test-import1", - "uri": "vstfs:///Build/Definition/10", - "path": "\\", - "type": 2, - "queueStatus": 0, - "revision": 1, - "createdDate": "2022-02-17T19:05:52.500Z", + "name": "Azure Pipelines", + "url": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126", + "pool": { + "name": "Azure Pipelines", + "isHosted": true + } + }, + "id": 10, + "name": "valet-classic-test-import1", + "uri": "vstfs:///Build/Definition/10", + "path": "\\", + "type": 2, + "queueStatus": 0, + "revision": 1, + "createdDate": "2022-02-17T19:05:52.500Z" } diff --git a/azure_devops/bootstrap/pipelines/classic/valet-classic2.json b/azure_devops/bootstrap/pipelines/classic/valet-classic2.json index fa966c1..b368aa1 100644 --- a/azure_devops/bootstrap/pipelines/classic/valet-classic2.json +++ b/azure_devops/bootstrap/pipelines/classic/valet-classic2.json @@ -1,243 +1,243 @@ { - "options": [ - { + "options": [ + { + "enabled": true, + "definition": { + "id": "5d58cc01-7c75-450c-be18-a388ddb129ec" + }, + "inputs": { + "branchFilters": "[\"+refs/heads/*\"]", + "additionalFields": "{}" + } + }, + { + "enabled": false, + "definition": { + "id": "a9db38f9-9fdc-478c-b0f9-464221e58316" + }, + "inputs": { + "workItemType": "Task", + "assignToRequestor": "true", + "additionalFields": "{}" + } + } + ], + "variables": { + "BuildConfiguration": { + "value": "release", + "allowOverride": true + }, + "BuildPlatform": { + "value": "any cpu", + "allowOverride": true + }, + "system.debug": { + "value": "false", + "allowOverride": true + } + }, + "properties": {}, + "tags": [], + "_links": [], + "buildNumberFormat": "$(date:yyyyMMdd)$(rev:.r)", + "jobAuthorizationScope": 1, + "jobTimeoutInMinutes": 60, + "jobCancelTimeoutInMinutes": 5, + "process": { + "phases": [ + { + "steps": [ + { + "environment": {}, "enabled": true, - "definition": { - "id": "5d58cc01-7c75-450c-be18-a388ddb129ec" + "continueOnError": false, + "alwaysRun": false, + "displayName": "Use NuGet 4.4.1", + "timeoutInMinutes": 0, + "retryCountOnTaskFailure": 0, + "condition": "succeeded()", + "task": { + "id": "2c65196a-54fd-4a02-9be8-d9d1837b7c5d", + "versionSpec": "0.*", + "definitionType": "task" }, "inputs": { - "branchFilters": "[\"+refs/heads/*\"]", - "additionalFields": "{}" + "versionSpec": "4.4.1", + "checkLatest": "false" } - }, - { - "enabled": false, - "definition": { - "id": "a9db38f9-9fdc-478c-b0f9-464221e58316" + }, + { + "environment": {}, + "enabled": true, + "continueOnError": false, + "alwaysRun": false, + "displayName": "NuGet restore", + "timeoutInMinutes": 0, + "retryCountOnTaskFailure": 0, + "condition": "succeeded()", + "task": { + "id": "333b11bd-d341-40d9-afcf-b32d5ce6f23b", + "versionSpec": "2.*", + "definitionType": "task" }, "inputs": { - "workItemType": "Task", - "assignToRequestor": "true", - "additionalFields": "{}" + "command": "restore", + "solution": "$(Parameters.solution)", + "selectOrConfig": "select", + "feedRestore": "", + "includeNuGetOrg": "true", + "nugetConfigPath": "", + "externalEndpoints": "", + "noCache": "false", + "disableParallelProcessing": "false", + "packagesDirectory": "", + "verbosityRestore": "Detailed", + "searchPatternPush": "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg", + "nuGetFeedType": "internal", + "feedPublish": "", + "publishPackageMetadata": "true", + "allowPackageConflicts": "false", + "externalEndpoint": "", + "verbosityPush": "Detailed", + "searchPatternPack": "**/*.csproj", + "configurationToPack": "$(BuildConfiguration)", + "outputDir": "$(Build.ArtifactStagingDirectory)", + "versioningScheme": "off", + "includeReferencedProjects": "false", + "versionEnvVar": "", + "requestedMajorVersion": "1", + "requestedMinorVersion": "0", + "requestedPatchVersion": "0", + "packTimezone": "utc", + "includeSymbols": "false", + "toolPackage": "false", + "buildProperties": "", + "basePath": "", + "verbosityPack": "Detailed", + "arguments": "" } - } - ], - "variables": { - "BuildConfiguration": { - "value": "release", - "allowOverride": true - }, - "BuildPlatform": { - "value": "any cpu", - "allowOverride": true - }, - "system.debug": { - "value": "false", - "allowOverride": true - } - }, - "properties": {}, - "tags": [], - "_links": [], - "buildNumberFormat": "$(date:yyyyMMdd)$(rev:.r)", - "jobAuthorizationScope": 1, - "jobTimeoutInMinutes": 60, - "jobCancelTimeoutInMinutes": 5, - "process": { - "phases": [ - { - "steps": [ - { - "environment": {}, - "enabled": true, - "continueOnError": false, - "alwaysRun": false, - "displayName": "Use NuGet 4.4.1", - "timeoutInMinutes": 0, - "retryCountOnTaskFailure": 0, - "condition": "succeeded()", - "task": { - "id": "2c65196a-54fd-4a02-9be8-d9d1837b7c5d", - "versionSpec": "0.*", - "definitionType": "task" - }, - "inputs": { - "versionSpec": "4.4.1", - "checkLatest": "false" - } - }, - { - "environment": {}, - "enabled": true, - "continueOnError": false, - "alwaysRun": false, - "displayName": "NuGet restore", - "timeoutInMinutes": 0, - "retryCountOnTaskFailure": 0, - "condition": "succeeded()", - "task": { - "id": "333b11bd-d341-40d9-afcf-b32d5ce6f23b", - "versionSpec": "2.*", - "definitionType": "task" - }, - "inputs": { - "command": "restore", - "solution": "$(Parameters.solution)", - "selectOrConfig": "select", - "feedRestore": "", - "includeNuGetOrg": "true", - "nugetConfigPath": "", - "externalEndpoints": "", - "noCache": "false", - "disableParallelProcessing": "false", - "packagesDirectory": "", - "verbosityRestore": "Detailed", - "searchPatternPush": "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg", - "nuGetFeedType": "internal", - "feedPublish": "", - "publishPackageMetadata": "true", - "allowPackageConflicts": "false", - "externalEndpoint": "", - "verbosityPush": "Detailed", - "searchPatternPack": "**/*.csproj", - "configurationToPack": "$(BuildConfiguration)", - "outputDir": "$(Build.ArtifactStagingDirectory)", - "versioningScheme": "off", - "includeReferencedProjects": "false", - "versionEnvVar": "", - "requestedMajorVersion": "1", - "requestedMinorVersion": "0", - "requestedPatchVersion": "0", - "packTimezone": "utc", - "includeSymbols": "false", - "toolPackage": "false", - "buildProperties": "", - "basePath": "", - "verbosityPack": "Detailed", - "arguments": "" - } - }, - { - "environment": {}, - "enabled": true, - "continueOnError": false, - "alwaysRun": false, - "displayName": "PowerShell Script", - "timeoutInMinutes": 0, - "retryCountOnTaskFailure": 0, - "condition": "succeeded()", - "task": { - "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1", - "versionSpec": "2.*", - "definitionType": "task" - }, - "inputs": { - "targetType": "inline", - "filePath": "", - "arguments": "", - "script": "# Write your PowerShell commands here.\n\nWrite-Host \"Hello World\"\n", - "errorActionPreference": "stop", - "warningPreference": "default", - "informationPreference": "default", - "verbosePreference": "default", - "debugPreference": "default", - "failOnStderr": "false", - "showWarnings": "false", - "ignoreLASTEXITCODE": "false", - "pwsh": "false", - "workingDirectory": "", - "runScriptInSeparateScope": "false" - } - } - ], - "name": "Agent job 1", - "refName": "Job_1", - "condition": "succeeded()", - "target": { - "executionOptions": { - "type": 0 - }, - "allowScriptsAuthAccessOption": false, - "type": 1 - }, - "jobAuthorizationScope": 1 + }, + { + "environment": {}, + "enabled": true, + "continueOnError": false, + "alwaysRun": false, + "displayName": "PowerShell Script", + "timeoutInMinutes": 0, + "retryCountOnTaskFailure": 0, + "condition": "succeeded()", + "task": { + "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1", + "versionSpec": "2.*", + "definitionType": "task" + }, + "inputs": { + "targetType": "inline", + "filePath": "", + "arguments": "", + "script": "# Write your PowerShell commands here.\n\nWrite-Host \"Hello World\"\n", + "errorActionPreference": "stop", + "warningPreference": "default", + "informationPreference": "default", + "verbosePreference": "default", + "debugPreference": "default", + "failOnStderr": "false", + "showWarnings": "false", + "ignoreLASTEXITCODE": "false", + "pwsh": "false", + "workingDirectory": "", + "runScriptInSeparateScope": "false" } + } ], + "name": "Agent job 1", + "refName": "Job_1", + "condition": "succeeded()", "target": { - "agentSpecification": { - "identifier": "windows-latest" - } + "executionOptions": { + "type": 0 + }, + "allowScriptsAuthAccessOption": false, + "type": 1 }, - "type": 1 + "jobAuthorizationScope": 1 + } + ], + "target": { + "agentSpecification": { + "identifier": "windows-latest" + } }, - "repository": { - "properties": { - "cleanOptions": "0", - "labelSources": "0", - "labelSourcesFormat": "$(build.buildNumber)", - "reportBuildStatus": "true", - "gitLfsSupport": "false", - "skipSyncSource": "false", - "checkoutNestedSubmodules": "false", - "fetchDepth": "0" - }, - "id": "", - "type": "TfsGit", - "name": "REPOTOREPLACE", - "url": "", - "defaultBranch": "refs/heads/main", - "clean": "false", - "checkoutSubmodules": false + "type": 1 + }, + "repository": { + "properties": { + "cleanOptions": "0", + "labelSources": "0", + "labelSourcesFormat": "$(build.buildNumber)", + "reportBuildStatus": "true", + "gitLfsSupport": "false", + "skipSyncSource": "false", + "checkoutNestedSubmodules": "false", + "fetchDepth": "0" }, - "processParameters": { - "inputs": [ - { - "aliases": [], - "options": {}, - "properties": {}, - "name": "solution", - "label": "Solution", - "defaultValue": "**\\*.sln", - "required": true, - "type": "filePath", - "helpMarkDown": "The path to the Visual Studio solution file or NuGet packages.config. Wildcards can be used. For example, `**\\\\*.sln` for all sln files in all sub folders." - } - ] + "id": "", + "type": "TfsGit", + "name": "REPOTOREPLACE", + "url": "", + "defaultBranch": "refs/heads/main", + "clean": "false", + "checkoutSubmodules": false + }, + "processParameters": { + "inputs": [ + { + "aliases": [], + "options": {}, + "properties": {}, + "name": "solution", + "label": "Solution", + "defaultValue": "**\\*.sln", + "required": true, + "type": "filePath", + "helpMarkDown": "The path to the Visual Studio solution file or NuGet packages.config. Wildcards can be used. For example, `**\\\\*.sln` for all sln files in all sub folders." + } + ] + }, + "quality": 1, + "authoredBy": { + "displayName": "David Kalmin", + "url": "https://spsprodcus5.vssps.visualstudio.com/A8ceff4ff-6429-4de3-9c39-fd7f0b1fb05a/_apis/Identities/a886d3a4-5700-6920-a3e4-6dadf46e7614", + "_links": { + "avatar": { + "href": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" + } }, - "quality": 1, - "authoredBy": { - "displayName": "David Kalmin", - "url": "https://spsprodcus5.vssps.visualstudio.com/A8ceff4ff-6429-4de3-9c39-fd7f0b1fb05a/_apis/Identities/a886d3a4-5700-6920-a3e4-6dadf46e7614", - "_links": { - "avatar": { - "href": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" - } - }, - "id": "a886d3a4-5700-6920-a3e4-6dadf46e7614", - "uniqueName": "davidkalmin@microsoft.com", - "imageUrl": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0", - "descriptor": "aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" + "id": "a886d3a4-5700-6920-a3e4-6dadf46e7614", + "uniqueName": "davidkalmin@microsoft.com", + "imageUrl": "https://dev.azure.com/microsoft-bootcamp/_apis/GraphProfile/MemberAvatars/aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0", + "descriptor": "aad.YTg4NmQzYTQtNTcwMC03OTIwLWEzZTQtNmRhZGY0NmU3NjE0" + }, + "drafts": [], + "queue": { + "_links": { + "self": { + "href": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126" + } }, - "drafts": [], - "queue": { - "_links": { - "self": { - "href": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126" - } - }, - "name": "Azure Pipelines", - "url": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126", - "pool": { - "name": "Azure Pipelines", - "isHosted": true - } - }, - "id": 10, - "name": "valet-classic-test-import2", - "uri": "vstfs:///Build/Definition/10", - "path": "\\", - "type": 2, - "queueStatus": 0, - "revision": 1, - "createdDate": "2022-02-17T19:05:52.500Z", + "name": "Azure Pipelines", + "url": "https://dev.azure.com/microsoft-bootcamp/_apis/build/Queues/126", + "pool": { + "name": "Azure Pipelines", + "isHosted": true + } + }, + "id": 10, + "name": "valet-classic-test-import2", + "uri": "vstfs:///Build/Definition/10", + "path": "\\", + "type": 2, + "queueStatus": 0, + "revision": 1, + "createdDate": "2022-02-17T19:05:52.500Z" } diff --git a/azure_devops/bootstrap/pipelines/yml/valet-mapper-example.yml b/azure_devops/bootstrap/pipelines/yml/valet-custom-transformer-example.yml similarity index 100% rename from azure_devops/bootstrap/pipelines/yml/valet-mapper-example.yml rename to azure_devops/bootstrap/pipelines/yml/valet-custom-transformer-example.yml diff --git a/azure_devops/bootstrap/setup b/azure_devops/bootstrap/setup new file mode 100755 index 0000000..e225a95 --- /dev/null +++ b/azure_devops/bootstrap/setup @@ -0,0 +1,178 @@ +#!/usr/bin/env ruby +require "json" +require "net/http" +require "optparse" +require "pathname" +require "pry" + +options = { + code_assets_dir: "code", + pipeline_assets_dir: "pipelines", + root_dir: File.join(ENV["CODESPACE_VSCODE_FOLDER"], "azure_devops/bootstrap") +} + +OptionParser.new do |opt| + opt.on('--organization ORGANIZATION') { |o| options[:organization] = o } + opt.on('--project PROJECT') { |o| options[:project] = o } + opt.on('--access-token ACCESS_TOKEN') { |o| options[:access_token] = o } +end.parse! + +[:organization, :project, :access_token].each do |key| + raise OptionParser::MissingArgument, key if options[key].nil? +end + +def post_request(uri, body, access_token) + Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| + request = Net::HTTP::Post.new(uri) + request.basic_auth "", access_token + request.body = body.to_json + request.content_type = 'application/json' + + response = http.request request + + yield(response) if block_given? + + sleep(5) + + JSON.parse(response.body) + end +end + +def create_project(options) + organization = options[:organization] + project = options[:project] + access_token = options[:access_token] + + puts "Creating project #{project} in organization #{organization}..." + uri = URI("https://dev.azure.com/#{organization}/_apis/projects?api-version=6.0") + + project_to_create = { + name: project, + description: "Project to be used for Valet Labs", + capabilities: { + versioncontrol: { + sourceControlType: "Git" + }, + processTemplate: { + templateTypeId: "6b724908-ef14-45cf-84f8-768b5384da45" + } + } + } + + post_request(uri, project_to_create, access_token) do |response| + raise "Error creating project (#{response.code}:#{response.message})" unless response.code.start_with?("20") + end +end + +def create_repository(options) + organization = options[:organization] + project = options[:project] + # use the default repository created when the project is created + repository = options[:project] + access_token = options[:access_token] + root_dir = options[:root_dir] + directories = [options[:code_assets_dir], options[:pipeline_assets_dir]] + + puts "Creating repository #{repository}..." + uri = URI("https://dev.azure.com/#{organization}/#{project}/_apis/git/repositories/#{repository}/pushes?api-version=7.1-preview.2") + + root = Pathname.new(root_dir) + repository_to_create = { + refUpdates: [{ + name: "refs/heads/main", + oldObjectId: "0000000000000000000000000000000000000000" + }], + commits: [{ + comment: "Initial commit.", + changes: directories.map do |directory| + Dir[File.join(root_dir, directory, "**/*")].reject {|f| File.directory?(f) }.map do |entry| + { + changeType: "add", + item: { + path: File.join("/", Pathname.new(entry).relative_path_from(root).to_s) + }, + newContent: { + content: File.read(entry), + contentType: "rawText" + } + } + end + end.flatten + }] + } + + post_request(uri, repository_to_create, access_token) do |response| + raise "Error creating repository (#{response.code}:#{response.message})" unless response.code.start_with?("20") + end +end + +def create_yaml_pipelines(options, repository) + organization = options[:organization] + project = options[:project] + repository_name = repository.dig("repository", "name") + repository_id = repository.dig("repository", "id") + access_token = options[:access_token] + root_dir = options[:root_dir] + pipeline_assets_dir = options[:pipeline_assets_dir] + + puts "Creating yaml pipelines..." + + uri = URI("https://dev.azure.com/#{organization}/#{project}/_apis/pipelines?api-version=6.0-preview.1") + root = Pathname.new(root_dir) + Dir[File.join(root_dir, pipeline_assets_dir, "yml", "*")].each do |entry| + puts "Creating pipeline #{entry}..." + + pipeline_to_create = { + folder: "pipelines", + name: File.basename(entry, ".yml"), + configuration: { + type: "yaml", + path: File.join("/", Pathname.new(entry).relative_path_from(root).to_s), + repository: { + id: repository_id, + name: repository_name, + type: "azureReposGit" + } + } + } + + post_request(uri, pipeline_to_create, access_token) do |response| + raise "Error creating pipeline (#{response.code}:#{response.message})" unless response.code.start_with?("20") + end + end +end + +def create_classic_pipelines(options, repository) + organization = options[:organization] + project = options[:project] + repository_name = repository.dig("repository", "name") + repository_id = repository.dig("repository", "id") + access_token = options[:access_token] + root_dir = options[:root_dir] + pipeline_assets_dir = options[:pipeline_assets_dir] + + puts "Creating classic pipelines..." + + uri = URI("https://dev.azure.com/#{organization}/#{project}/_apis/build/definitions?api-version=7.1-preview.7") + root = Pathname.new(root_dir) + Dir[File.join(root_dir, pipeline_assets_dir, "classic", "*")].each do |entry| + puts "Creating pipeline #{entry}..." + + pipeline_to_create = JSON.parse(File.read(entry)) + + pipeline_to_create["repository"]["name"] = repository_name + pipeline_to_create["repository"]["id"] = repository_id + + post_request(uri, pipeline_to_create, access_token) do |response| + raise "Error creating pipeline (#{response.code}:#{response.message})" unless response.code.start_with?("20") + end + end +end + + +create_project(options) +repository = create_repository(options) +create_yaml_pipelines(options, repository) +create_classic_pipelines(options, repository) + +puts "Success!" \ No newline at end of file diff --git a/azure_devops/valet-migrate-custom-lab.md b/azure_devops/valet-migrate-custom-lab.md index eb7ca67..ffe7725 100644 --- a/azure_devops/valet-migrate-custom-lab.md +++ b/azure_devops/valet-migrate-custom-lab.md @@ -15,9 +15,9 @@ In this lab, you will create a custom plugin that transforms some of the existin 4. Complete the [Valet migrate lab](valet-migrate-lab.md). ## Identify the Azure DevOps pipeline ID to use -You will need the `valet-mapper-example` Azure DevOps pipeline ID to perform the migration +You will need the `valet-custom-transformer-example` Azure DevOps pipeline ID to perform the migration 1. Go to the `valet/ValetBootstrap/pipelines` folder -2. Open the `valet/ValetBootstrap/pipelines/valet-mapper-example.config.json` file +2. Open the `valet/ValetBootstrap/pipelines/valet-custom-transformer-example.config.json` file 3. Look for the `web - href` link 4. At the end of the link is the pipeline ID. Copy or note the ID.