From 003116bd6f74bdd355a7ec9f852c2f9bcee8630d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Tue, 4 Jan 2022 13:40:39 +0000 Subject: [PATCH 1/5] chore(pipelines): cleanup and new CD-Containers --- .../init/Builds/CD-Containers.json | 83 ++ .../init/Builds/CD-Containers.yml | 952 ++++++++++++++++++ .../template_feed/init/Builds/CI-Publish.yml | 20 - .../template_feed/init/Builds/CI-Release.json | 2 +- .../template_feed/init/Builds/CI-Release.yml | 55 +- .../EnvironmentConfigs/%EnvironmentName%.yml | 31 + .../EnvironmentConfigs/GlobalVariables.yml | 2 +- 7 files changed, 1090 insertions(+), 55 deletions(-) create mode 100644 cmf-cli/resources/template_feed/init/Builds/CD-Containers.json create mode 100644 cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml create mode 100644 cmf-cli/resources/template_feed/init/EnvironmentConfigs/%EnvironmentName%.yml diff --git a/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json new file mode 100644 index 00000000..159e1a3b --- /dev/null +++ b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json @@ -0,0 +1,83 @@ +{ + "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": [], + "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" +} \ No newline at end of file diff --git a/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml new file mode 100644 index 00000000..5ebc8d59 --- /dev/null +++ b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml @@ -0,0 +1,952 @@ +# CM PI Continuous Deployment Containers Pipeline +pool: + name: Releases + +# A pipeline with no CI trigger +trigger: none + +# A pipeline with no PR trigger +pr: none + +# Pipeline tiggered by CI-Publish +resources: + pipelines: + - pipeline: CIPublish + source: CI-Publish + branch: $(Build.SourceBranch) + project: '<%= $CLI_PARAM_ProjectName %>' + trigger: true + +variables: + - group: Docker Variables + - template: ../EnvironmentConfigs/GlobalVariables.yml # Template reference to global variables + - template: ../EnvironmentConfigs/${{ parameters.Environment }}.yml # Template reference to environment variables + +# Set in runtime +parameters: +- name: Environment + displayName: AzureDevOps Environment name + type: string + default: <%= $CLI_PARAM_EnvironmentName %> + values: + - <%= $CLI_PARAM_EnvironmentName %> +# Stages to Run +- name: ExecuteAllStages + displayName: Execute All Stages + type: boolean + default: true +- name: DropDatabase + displayName: Drop Database + type: boolean + default: false +- name: Installation + displayName: Installation + type: boolean + default: false +- name: RestorePoint + displayName: Restore Point + type: boolean + default: false +- name: RunTestMasterData + displayName: Run Test MasterData + type: boolean + default: false +- name: DailyBackup + displayName: Daily Backup + type: boolean + default: false +- name: RunTests + displayName: Run Tests + type: boolean + default: false +- name: ApprovalAndRetain + displayName: Approval and Retain + type: boolean + default: false +- name: SetNewRestorePoint + displayName: Set New RestorePoint + type: boolean + default: false + +name: Release-$(Build.BuildId) +stages: + - stage: "DropDatabase" + displayName: "Drop Database" + condition: or( eq('${{ parameters.ExecuteAllStages }}', true), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.DropDatabase }}', true) ) ) + jobs: + - job: "DropDatabase" + displayName: "Drop Database" + workspace: + clean: all + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + - task: PowerShell@2 + displayName: "Load environment config" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + if (Test-Path -Path $file -PathType Leaf) { + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.PSObject.Properties | ForEach-Object { + if (-not($_.Value -eq "" -or $_.Value -eq $nil)) { + Write-Output "##vso[task.setvariable variable=$($_.Name)]$($_.Value)" + } + } + } else { + Write-Output "'$file' not found" + } + + - task: SqlDacpacDeploymentOnMachineGroup@0 + displayName: "Drop ONLINE database" + inputs: + TaskType: 'sqlInline' + InlineSql: | + IF EXISTS (SELECT name from sys.databases WHERE (name = N'$(SYSTEM_NAME)')) + BEGIN + EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'$(SYSTEM_NAME)' + ALTER DATABASE [$(SYSTEM_NAME)] SET SINGLE_USER WITH ROLLBACK IMMEDIATE + DROP DATABASE IF EXISTS $(SYSTEM_NAME) + END; + ServerName: '$(DATABASE_ONLINE_MSSQL_ADDRESS)' + DatabaseName: 'master' + AuthScheme: 'sqlServerAuthentication' + SqlUsername: '$(DATABASE_ONLINE_MSSQL_USERNAME)' + SqlPassword: '$(DATABASE_ONLINE_MSSQL_PASSWORD)' + + - task: SqlDacpacDeploymentOnMachineGroup@0 + displayName: "Drop ODS database" + inputs: + TaskType: 'sqlInline' + InlineSql: | + IF EXISTS (SELECT name from sys.databases WHERE (name = N'$(SYSTEM_NAME)ODS')) + BEGIN + EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'$(SYSTEM_NAME)ODS' + ALTER DATABASE [$(SYSTEM_NAME)ODS] SET SINGLE_USER WITH ROLLBACK IMMEDIATE + DROP DATABASE IF EXISTS $(SYSTEM_NAME)ODS + END; + ServerName: '$(DATABASE_ODS_MSSQL_ADDRESS)' + DatabaseName: 'master' + AuthScheme: 'sqlServerAuthentication' + SqlUsername: '$(DATABASE_ODS_MSSQL_USERNAME)' + SqlPassword: '$(DATABASE_ODS_MSSQL_PASSWORD)' + + - task: SqlDacpacDeploymentOnMachineGroup@0 + displayName: "Drop DWH database" + inputs: + TaskType: 'sqlInline' + InlineSql: | + IF EXISTS (SELECT name from sys.databases WHERE (name = N'$(SYSTEM_NAME)DWH')) + BEGIN + EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'$(SYSTEM_NAME)DWH' + ALTER DATABASE [$(SYSTEM_NAME)DWH] SET SINGLE_USER WITH ROLLBACK IMMEDIATE + DROP DATABASE IF EXISTS $(SYSTEM_NAME)DWH + END; + ServerName: '$(DATABASE_DWH_MSSQL_ADDRESS)' + DatabaseName: 'master' + AuthScheme: 'sqlServerAuthentication' + SqlUsername: '$(DATABASE_DWH_MSSQL_USERNAME)' + SqlPassword: '$(DATABASE_DWH_MSSQL_PASSWORD)' + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "Installation" + displayName: "Installation" + condition: or( and( eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.Installation }}', true) ) ) + jobs: + - job: "Installation" + displayName: "Installation" + workspace: + clean: all + steps: + - checkout: none + + # Clean deploy folder + - task: DeleteFiles@1 + displayName: 'Clean deploy folder' + inputs: + SourceFolder: '${{ variables.CandidatePackages }}' + Contents: '**' + + # Download Package Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Package Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Package' + downloadPath: '${{ variables.CandidatePackages }}' + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + # Copy External Package Dependencies + # use Node Tool + - task: NodeTool@0 + displayName: 'Use Node ${{ variables.NodeVersion }}' + inputs: + versionSpec: ${{ variables.NodeVersion }} + + # Install cmf-pipeline + - task: PowerShell@2 + displayName: 'Install cmf-pipeline@${{ variables.CmfPipelineVersion }}' + inputs: + pwsh: true + failOnStderr: false + workingDirectory: $(Agent.TempDirectory) + targetType: inline + script: | + npm install --no-save @criticalmanufacturing/cmf-pipeline@${{ variables.CmfPipelineVersion }} --registry ${{ variables.CmfPipelineRepository }} + + - task: PowerShell@2 + displayName: "cmf-pipeline copyDependencies" + inputs: + targetType: 'inline' + script: | + $(Agent.TempDirectory)/node_modules/@criticalmanufacturing/cmf-pipeline/dist/win-x64/cmf-pipeline copyDependencies Configurations/dependencies.json ${{ variables.CandidatePackages }}/Package + pwsh: true + + - task: replacetokens@4 + displayName: 'Replace tokens in parameters files' + inputs: + rootDirectory: 'Configurations' + targetFiles: '**/*.json' + keepToken: true + tokenPrefix: '#{' + tokenSuffix: '}#' + + - task: PowerShell@2 + displayName: "Get portal-sdk" + inputs: + pwsh: true + failOnStderr: false + workingDirectory: $(Agent.TempDirectory) + targetType: inline + script: | + npm install --no-save @criticalmanufacturing/portal --registry ${{ variables.CmfCliRepository }} + + - task: PowerShell@2 + displayName: "Load environment config" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + if (Test-Path -Path $file -PathType Leaf) { + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.PSObject.Properties | ForEach-Object { + if (-not($_.Value -eq "" -or $_.Value -eq $nil)) { + Write-Output "##vso[task.setvariable variable=$($_.Name)]$($_.Value)" + } + } + } else { + Write-Output "'$file' not found" + } + + - task: PowerShell@2 + displayName: "Generate Environment Installation Parameters" + inputs: + targetType: 'inline' + failOnStderr: true + pwsh: true + script: | + $CmfPackageJsonFile = Get-Item "./Configurations/cmfpackage.json" + $CmfPackageJson = Get-Content -Raw -Path $CmfPackageJsonFile | ConvertFrom-Json + + $PackageId = $CmfPackageJson.'packageId' + $PackageVersion = $CmfPackageJson.'version' + $PackageIdentifier = $PackageId + '@' + $PackageVersion + + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.ENV_MANAGER_BOOT_PACKAGE = $PackageIdentifier + + $packageSourceShare = "$(CandidatePackages)/Package" + $addrPackageSourceShare = (($packageSourceShare -split "\\" | Where { $_ -ne "" })[0] -replace ".cmf.criticalmanufacturing.com") + $envConfig.DockerSwarm_Volume_NetworkShare_Path_package_source_share = $packageSourceShare; + $envConfig.DockerSwarm_Volume_NetworkShare_Address_package_source_share = "$addrPackageSourceShare.cmf.criticalmanufacturing.com" + + Write-Output "Installing package $PackageIdentifier" + $envConfig | ConvertTo-Json -Depth 10 | set-content "$(Agent.TempDirectory)/install-package.json" + + # Installation with customization + - task: PowerShell@2 + displayName: "Installation" + inputs: + pwsh: true + targetType: 'inline' + script: | + $packageSourceShare = "$(CandidatePackages)/Package" + Copy-Item -Path $(DATABASE_NETWORK_SHARE)/approved/Cmf.FullBackup.*.zip -Destination $packageSourceShare -Force + if (Test-Path "Configurations/EnvironmentConfigs/devopscenter.qa.json" -PathType leaf) + { + Copy-Item -Path Configurations/EnvironmentConfigs/devopscenter.qa.json -Destination $env:AGENT_TEMPDIRECTORY/node_modules/@criticalmanufacturing/portal/bin/appsettings.json -Force + } + Write-Host PAT: $(CustomerPortalPAT) + & $env:AGENT_TEMPDIRECTORY/node_modules/@criticalmanufacturing/portal/bin/cmf-portal.exe login --token $(CustomerPortalPAT) --verbose + & $env:AGENT_TEMPDIRECTORY/node_modules/@criticalmanufacturing/portal/bin/cmf-portal.exe deploy ` + --name "${{ variables.CustomerEnvironmentName }}" ` + --customer-infrastructure-name "DS Integration Environments" ` + --parameters "$(Agent.TempDirectory)/install-package.json" ` + --license "${{ variables.LicenseName }}" ` + --site "${{ variables.SiteName }}" ` + --target "${{ variables.DeploymentTarget }}" ` + --package="${{ variables.DeploymentPackage }}" ` + --replace-tokens TargetVersion=${{ variables.MESVersion }} --verbose + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "RestorePoint" + displayName: "Restore Point" + condition: or( and( eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.RestorePoint }}', true) ) ) + jobs: + - job: "RestorePoint" + displayName: "Restore Point" + workspace: + clean: all + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + - task: PowerShell@2 + displayName: "Load environment config" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + if (Test-Path -Path $file -PathType Leaf) { + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.PSObject.Properties | ForEach-Object { + if (-not($_.Value -eq "" -or $_.Value -eq $nil)) { + Write-Output "##vso[task.setvariable variable=$($_.Name)]$($_.Value)" + } + } + } else { + Write-Output "'$file' not found" + } + + - task: PowerShell@2 + displayName: "Generate backup parameters" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "$env:AGENT_TEMPDIRECTORY/backup_parameters.json" + $json = @" + { + "Product.SystemName": "$(SYSTEM_NAME)", + "Product.Database.BackupShare": "$('$(DATABASE_NETWORK_SHARE)' -replace '\\', '\\')", + "Product.BackupDatabase.UseCompression": true, + "Package[Product.Database.Online].Database.Server": "$('$(DATABASE_ONLINE_MSSQL_ADDRESS)' -replace '\\', '\\')", + "Package[Product.Database.Online].Database.User": "$('$(DATABASE_ONLINE_MSSQL_USERNAME)' -replace '\\', '\\')", + "Package[Product.Database.Online].Database.Password": "$('$(DATABASE_ONLINE_MSSQL_PASSWORD)' -replace '\\', '\\')", + "Package[Product.Database.Ods].Database.Server": "$('$(DATABASE_ODS_MSSQL_ADDRESS)' -replace '\\', '\\')", + "Package[Product.Database.Ods].Database.User": "$('$(DATABASE_ODS_MSSQL_USERNAME)' -replace '\\', '\\')", + "Package[Product.Database.Ods].Database.Password": "$('$(DATABASE_ODS_MSSQL_PASSWORD)' -replace '\\', '\\')", + "Package[Product.Database.Dwh].Database.Server": "$('$(DATABASE_DWH_MSSQL_ADDRESS)' -replace '\\', '\\')", + "Package[Product.Database.Dwh].Database.User": "$('$(DATABASE_DWH_MSSQL_USERNAME)' -replace '\\', '\\')", + "Package[Product.Database.Dwh].Database.Password": "$('$(DATABASE_DWH_MSSQL_PASSWORD)' -replace '\\', '\\')" + } + "@ + $json | set-content $file + Write-Host $json + + - task: PowerShell@2 + displayName: "Full Backup" + inputs: + targetType: 'inline' + script: | + Remove-Item -Path $(DATABASE_NETWORK_SHARE)/Cmf.FullBackup.*.zip -Force -Verbose + Remove-Item -Path $(DATABASE_NETWORK_SHARE)/*.bak -Force -Verbose + Remove-Item -Path $(DATABASE_NETWORK_SHARE)/FullBackup -Force -Verbose -Recurse -ErrorAction Ignore + New-Item -ItemType Directory -Path "$(DATABASE_NETWORK_SHARE)" -Name "FullBackup" -Force + & tools\CmfDeploy.exe backup --parameters $env:AGENT_TEMPDIRECTORY/backup_parameters.json --packageSources .\DFPackages + Move-Item -Path $(DATABASE_NETWORK_SHARE)/Cmf.FullBackup.*.zip -Destination $(DATABASE_NETWORK_SHARE)/FullBackup -Force + pwsh: true + workingDirectory: 'C:\tools\Cmf.Deployment.Framework' + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "RunTestMasterData" + displayName: "Run Test Master Data" + condition: or( and( eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.RunTestMasterData }}', true) ) ) + jobs: + - job: "RunTestMasterData" + displayName: "Run Test Master Data" + workspace: + clean: all + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + # Download Tests Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Tests Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Tests' + downloadPath: '${{ variables.CandidatePackages }}' + continueOnError: true + + # Verify if Artifact exists - Tests.MasterData + - task: PowerShell@2 + displayName: Verify if Artifact exists - Tests.MasterData + inputs: + targetType: inline + script: | + $masterDataFiles = "${{ variables.CandidatePackages }}/Tests/*MasterData*.zip" + Write-Host "##vso[task.setVariable variable=ArtifactExists;]false" + + if (Get-ChildItem -Path $masterDataFiles) + { + Write-Host "##vso[task.setVariable variable=ArtifactExists;]true" + } + + - task: replacetokens@4 + displayName: 'Replace tokens in parameters files' + inputs: + rootDirectory: 'Configurations' + targetFiles: '**/*.json' + keepToken: true + tokenPrefix: '#{' + tokenSuffix: '}#' + + - task: PowerShell@2 + displayName: "Load environment config" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + if (Test-Path -Path $file -PathType Leaf) { + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.PSObject.Properties | ForEach-Object { + if (-not($_.Value -eq "" -or $_.Value -eq $nil)) { + Write-Output "##vso[task.setvariable variable=$($_.Name)]$($_.Value)" + } + } + } else { + Write-Output "'$file' not found" + } + - task: PowerShell@2 + displayName: "Generate parameters" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "$env:AGENT_TEMPDIRECTORY/parameters.json" + $json = @" + { + "Product.SystemName": "$(SYSTEM_NAME)", + "Packages.Root.TargetDirectory": "", + "Package[Product.Database.Online].Database.Server": "$('$(DATABASE_ONLINE_MSSQL_ADDRESS)' -replace '\\', '\\')", + "Package[Product.Database.Online].Database.User": "$('$(DATABASE_ONLINE_MSSQL_USERNAME)' -replace '\\', '\\')", + "Package[Product.Database.Online].Database.Password": "$('$(DATABASE_ONLINE_MSSQL_PASSWORD)' -replace '\\', '\\')", + } + "@ + $json | set-content $file + Write-Host $json + + - task: PowerShell@2 + displayName: "MasterData Loading" + inputs: + targetType: 'inline' + script: | + $masterDataFiles = "${{ variables.CandidatePackages }}/Tests/*MasterData*.zip" + + Get-ChildItem $masterDataFiles | foreach { + $PackageId = [regex]::split($_.BaseName, ".[0-9].[0-9].[0-9]")[0]; + $PackageVersion = ($_.BaseName-replace "$PackageId." ); + + $PackageIdentifier = $PackageId + '@' + $PackageVersion + + & tools\CmfDeploy.exe install $PackageIdentifier --parameters $env:AGENT_TEMPDIRECTORY/parameters.json --packageSources="${{ variables.CandidatePackages }}/Tests" -logFileLocation "${{ variables.CandidatePackages }}" + } + + pwsh: true + workingDirectory: 'C:\tools\Cmf.Deployment.Framework' + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "DailyBackup" + displayName: "Daily Backup" + condition: or( and( eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.DailyBackup }}', true) ) ) + jobs: + - job: "DailyBackup" + displayName: "Daily Backup" + workspace: + clean: all + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + - task: PowerShell@2 + displayName: "Load environment config" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + if (Test-Path -Path $file -PathType Leaf) { + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.PSObject.Properties | ForEach-Object { + if (-not($_.Value -eq "" -or $_.Value -eq $nil)) { + Write-Output "##vso[task.setvariable variable=$($_.Name)]$($_.Value)" + } + } + } else { + Write-Output "'$file' not found" + } + + - task: PowerShell@2 + displayName: "Generate backup parameters" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "$env:AGENT_TEMPDIRECTORY/backup_parameters.json" + $json = @" + { + "Product.SystemName": "$(SYSTEM_NAME)", + "Product.Database.BackupShare": "$('$(DATABASE_NETWORK_SHARE)' -replace '\\', '\\')", + "Product.BackupDatabase.UseCompression": true, + "Package[Product.Database.Online].Database.Server": "$('$(DATABASE_ONLINE_MSSQL_ADDRESS)' -replace '\\', '\\')", + "Package[Product.Database.Online].Database.User": "$('$(DATABASE_ONLINE_MSSQL_USERNAME)' -replace '\\', '\\')", + "Package[Product.Database.Online].Database.Password": "$('$(DATABASE_ONLINE_MSSQL_PASSWORD)' -replace '\\', '\\')" + } + "@ + $json | set-content $file + Write-Host $json + + # TODO: avoid colision between Full and Daily backups, both will generate a Cmf.FullBackup.Online..zip + - task: PowerShell@2 + displayName: "Daily Backup" + inputs: + targetType: 'inline' + script: | + Remove-Item -Path $(DATABASE_NETWORK_SHARE)/Cmf.FullBackup.*.zip -Force -Verbose + Remove-Item -Path $(DATABASE_NETWORK_SHARE)/*.bak -Force -Verbose + & tools\CmfDeploy.exe backup --parameters $env:AGENT_TEMPDIRECTORY/backup_parameters.json --packageSources .\DFPackages + Move-Item -Path $(DATABASE_NETWORK_SHARE)/Cmf.FullBackup.*.zip -Destination $(DATABASE_NETWORK_SHARE)/DailyBackup -Force + pwsh: true + workingDirectory: 'C:\tools\Cmf.Deployment.Framework' + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "RunTests" + displayName: "Run Tests" + condition: or( and( eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.RunTests }}', true) ) ) + jobs: + - job: "RunTests" + timeoutInMinutes: 720 # 12 hours + displayName: "Run Tests" + workspace: + clean: all + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + # Copy Copy global.json to root + - task: CopyFiles@2 + displayName: 'Copy global.json to root' + inputs: + SourceFolder: Configurations + Contents: 'global.json' + TargetFolder: '.' + + # Download Tests Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Tests Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Tests' + downloadPath: '$(Build.SourcesDirectory)' + continueOnError: true + + # Verify if Artifact exists - Tests + - task: PowerShell@2 + displayName: Verify if Artifact exists - Tests + inputs: + targetType: inline + script: | + Write-Host "##vso[task.setVariable variable=ArtifactExists;]false" + $artifactPath = "$(Build.SourcesDirectory)/Tests/*.zip" + Write-Host "$artifactPath" + if (Get-ChildItem -Path $artifactPath) + { + ls $artifactPath + Get-ChildItem $artifactPath | foreach { + $targetDirectory = "$(Build.SourcesDirectory)/TestExecution/" + $_.BaseName + Write-Host "$_ -> $targetDirectory" + Expand-Archive $_ -DestinationPath $targetDirectory -Force + } + Write-Host "##vso[task.setVariable variable=ArtifactExists;]true" + } + else + { + Write-Host "If fails" + } + Write-Host "$Env:ArtifactExists" + + # UseDotNet + - task: UseDotNet@2 + displayName: 'Use Repository specified .NET Core version' + inputs: + packageType: 'sdk' + useGlobalJson: true + + # Copy RunSettings to TestExecution + - task: CopyFiles@2 + displayName: 'Copy RunSettings to TestExecution' + inputs: + SourceFolder: Configurations + Contents: 'RunSettings/**' + TargetFolder: 'TestExecution' + + # Run Tests - Business + - task: VSTest@2 + displayName: "Run Tests - Business" + inputs: + testAssemblyVer2: '**\*.Biz.dll' + searchFolder: $(System.DefaultWorkingDirectory) + resultsFolder: '$(Agent.TempDirectory)\TestResults' + runSettingsFile: 'TestExecution\RunSettings\${{ variables.RunSettings }}' + testRunTitle: "Business Tests" + rerunFailedTests: true + rerunType: "basedOnTestFailurePercentage" # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount + rerunFailedThreshold: "30" + rerunMaxAttempts: "3" + continueOnError: true + condition: eq(variables['ArtifactExists'], true) + + # Run Tests - HTML + - task: VSTest@2 + displayName: "Run Tests - HTML" + inputs: + testAssemblyVer2: '**\*.GUI.dll' + searchFolder: $(System.DefaultWorkingDirectory) + resultsFolder: '$(Agent.TempDirectory)\TestResults' + runSettingsFile: 'TestExecution\RunSettings\${{ variables.RunSettings }}' + testRunTitle: "HTML Tests" + rerunFailedTests: true + rerunType: "basedOnTestFailurePercentage" # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount + rerunFailedThreshold: "30" + rerunMaxAttempts: "3" + continueOnError: true + condition: eq(variables['ArtifactExists'], true) + + # Run Tests - IoT + - task: VSTest@2 + displayName: "Run Tests - IoT" + inputs: + testAssemblyVer2: '**\*.IoT.dll' + searchFolder: $(System.DefaultWorkingDirectory) + resultsFolder: '$(Agent.TempDirectory)\TestResults' + platform: latest + runSettingsFile: 'TestExecution\RunSettings\${{ variables.RunSettings }}' + testRunTitle: "IoT Tests" + rerunFailedTests: true + rerunType: "basedOnTestFailurePercentage" # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount + rerunFailedThreshold: "30" + rerunMaxAttempts: "3" + continueOnError: true + condition: eq(variables['ArtifactExists'], true) + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "ApprovalAndRetain" + displayName: "Approval and Retain" + condition: or( and( eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.ApprovalAndRetain }}', true) ) ) + jobs: + - deployment: + timeoutInMinutes: 2880 # 48 hours + displayName: "Approval and Retain" + workspace: + clean: all + environment: ${{ parameters.Environment }} + cancelTimeoutInMinutes: 2880 # 48 hours + strategy: + runOnce: + deploy: + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + # Get package version + - task: PowerShell@2 + displayName: 'Get package version' + inputs: + targetType: inline + script: | + $CmfPackageJsonFile = Get-Item "./Configurations/cmfpackage.json" + $CmfPackageJson = Get-Content -Raw -Path $CmfPackageJsonFile | ConvertFrom-Json + $PackVersion = $CmfPackageJson.'version' + $PackageId = $CmfPackageJson.'packageId' + Write-Host "PackVersion = $PackVersion" + Write-Host "PackageId = $PackageId" + echo "##vso[task.setvariable variable=PackageVersion;isOutput=true]$PackVersion" + echo "##vso[task.setvariable variable=PackageId;isOutput=true]$PackageId" + name: GetPackageVersion + + # Get Date + - task: PowerShell@2 + displayName: "Get Date" + inputs: + pwsh: false + targetType: inline + script: | + $date=$(Get-Date -Format "yyyyMMdd"); + Write-Host "##vso[task.setvariable variable=time]$date" + continueOnError: false + + # Tag Git Source + - task: git-tag-on-release-task@9 + displayName: "Tag Git Source" + inputs: + staticTagName: "<%= $CLI_PARAM_Tenant %>-$(time)-$(GetPackageVersion.PackageVersion)" + + # Retain indefinitely current release + - task: retainPipeline@3 + displayName: "Retain indefinitely current release" + inputs: + lock: true + + # Download Package Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Package Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Package' + downloadPath: 'PackageApproved' + + # Copy generated Packages to Repository + - task: CopyFiles@2 + displayName: 'Copy generated Packages From Repository' + inputs: + SourceFolder: 'PackageApproved/Package' + Contents: | + *.zip + TargetFolder: '${{ variables.ApprovedPackages }}' + OverWrite: false + + # Download Tests Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Tests Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Tests' + downloadPath: 'TestPackageApproved' + + # Copy generated Packages to Repository + - task: CopyFiles@2 + displayName: 'Copy generated Packages To Repository' + inputs: + SourceFolder: 'TestPackageApproved/Tests' + Contents: | + *.zip + TargetFolder: '${{ variables.ApprovedPackages }}' + OverWrite: false + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() + + - stage: "SetNewRestorePoint" + displayName: "Copy Full Backup packages to stack packages share" + condition: or( and( eq('${{ variables.SetNewRestorePoint }}', true), eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.SetNewRestorePoint }}', true) ) ) + jobs: + - job: "SetNewRestorePoint" + displayName: "Copy Full Backup packages to stack packages share" + workspace: + clean: all + steps: + - checkout: none + + # Download Configurations Artifacts + - task: DownloadBuildArtifacts@0 + displayName: "Download Configurations Artifacts" + inputs: + buildType: 'specific' + project: '<%= $CLI_PARAM_ProjectName %>' + pipeline: 'CI-Publish' + specificBuildWithTriggering: true + buildVersionToDownload: 'specific' + buildId: '$(resources.pipeline.CIPublish.runID)' + downloadType: 'single' + artifactName: 'Configurations' + downloadPath: '.' + + - task: PowerShell@2 + displayName: "Load environment config" + inputs: + pwsh: true + targetType: 'inline' + script: | + $file = "Configurations/EnvironmentConfigs/${{ variables.EnvironmentConfigName }}" + if (Test-Path -Path $file -PathType Leaf) { + $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json + $envConfig.PSObject.Properties | ForEach-Object { + if (-not($_.Value -eq "" -or $_.Value -eq $nil)) { + Write-Output "##vso[task.setvariable variable=$($_.Name)]$($_.Value)" + } + } + } else { + Write-Output "'$file' not found" + } + + # Copy full backup packages to stack package path + - task: PowerShell@2 + displayName: "Copy Cmf.FullBackup packages" + inputs: + pwsh: false + targetType: inline + failOnStderr: true + script: | + Copy-Item -Path $(DATABASE_NETWORK_SHARE)/FullBackup/Cmf.FullBackup.*.zip Copy-Item -Path $(DATABASE_NETWORK_SHARE)/Approved -Verbose -Force -Recurse + continueOnError: false + + # Clean + - task: PostBuildCleanup@3 + displayName: "Clean Agent Directories" + condition: always() diff --git a/cmf-cli/resources/template_feed/init/Builds/CI-Publish.yml b/cmf-cli/resources/template_feed/init/Builds/CI-Publish.yml index bc69c2df..250466e1 100644 --- a/cmf-cli/resources/template_feed/init/Builds/CI-Publish.yml +++ b/cmf-cli/resources/template_feed/init/Builds/CI-Publish.yml @@ -37,26 +37,6 @@ steps: - checkout: self persistCredentials: true -# BackupRestoreTools Artifact -- task: DownloadBuildArtifacts@0 - displayName: 'Download Build Artifacts - BackupRestore Tools' - inputs: - buildType: specific - project: 'COMMON' - pipeline: 'CI-BackupRestoreTools' - specificBuildWithTriggering: true - buildVersionToDownload: latestFromBranch - branchName: '${{ variables.CommonBranch }}' - downloadType: specific - downloadPath: 'Package' - artifactName: Cmf.BackupRestore.Tools -- task: CopyFiles@2 - displayName: Copy Cmf.BackupRestore.Tools - inputs: - SourceFolder: 'Package/Cmf.BackupRestore.Tools' - Contents: '**' - TargetFolder: 'FinalPackage' - # use Node Tool - task: NodeTool@0 displayName: 'Use Node ${{ variables.NodeVersion }}' diff --git a/cmf-cli/resources/template_feed/init/Builds/CI-Release.json b/cmf-cli/resources/template_feed/init/Builds/CI-Release.json index f9c4a87c..bffa04f3 100644 --- a/cmf-cli/resources/template_feed/init/Builds/CI-Release.json +++ b/cmf-cli/resources/template_feed/init/Builds/CI-Release.json @@ -86,7 +86,7 @@ "uri": "vstfs:///Build/Definition/1063", "path": "\\Releases", "type": 2, - "queueStatus": 0, + "queueStatus": 2, "revision": 14, "createdDate": "2021-02-19T12:33:15.143Z" } \ No newline at end of file diff --git a/cmf-cli/resources/template_feed/init/Builds/CI-Release.yml b/cmf-cli/resources/template_feed/init/Builds/CI-Release.yml index e24d0c81..35e6d064 100644 --- a/cmf-cli/resources/template_feed/init/Builds/CI-Release.yml +++ b/cmf-cli/resources/template_feed/init/Builds/CI-Release.yml @@ -22,6 +22,7 @@ resources: variables: - template: ../EnvironmentConfigs/GlobalVariables.yml # Template reference to global variables + - template: ../EnvironmentConfigs/${{ parameters.Environment }}.yml # Template reference to environment variables - name: RestoreIdentifier value: 'ORIGINAL' @@ -33,18 +34,6 @@ parameters: default: <%= $CLI_PARAM_EnvironmentName %> values: - <%= $CLI_PARAM_EnvironmentName %> -- name: RunSettings - displayName: RunSettings file name - type: string - default: integration.runsettings - values: - - integration.runsettings -- name: EnvironmentConfigName - displayName: EnvironmentConfig file name - type: string - default: <%= $CLI_PARAM_ReleaseEnvironmentConfig %> - values: - - <%= $CLI_PARAM_ReleaseEnvironmentConfig %> # Stages to Run - name: executeAllStages displayName: ExecuteAllStages @@ -109,7 +98,7 @@ stages: downloadType: 'single' artifactName: 'Configurations' downloadPath: '.' - + # Download Build Artifacts - BackupRestore Tools - task: DownloadBuildArtifacts@0 displayName: 'Download Build Artifacts - BackupRestore Tools' @@ -138,7 +127,7 @@ stages: displayName: 'Copy EnvironmentConfig to Server' inputs: SourceFolder: Configurations/EnvironmentConfigs - Contents: '${{ parameters.EnvironmentConfigName }}' + Contents: '${{ variables.EnvironmentConfigName }}' TargetFolder: BackupRestoreTools/EnvironmentConfigs # Restore DB @@ -148,7 +137,7 @@ stages: pwsh: false targetType: filePath filePath: '.\BackupRestoreTools\DeploymentTools\SystemRestore.ps1' - arguments: '-EnvironmentConfigName ${{ parameters.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreDBOnline:$true -RestoreDBODS:$true -RestoreDBDWH:$true -doNotStopHosts:$true' + arguments: '-EnvironmentConfigName ${{ variables.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreDBOnline:$true -RestoreDBODS:$true -RestoreDBDWH:$true -doNotStopHosts:$true' continueOnError: false # Restore Business Tier @@ -158,7 +147,7 @@ stages: pwsh: false targetType: filePath filePath: '.\BackupRestoreTools\DeploymentTools\SystemRestore.ps1' - arguments: '-EnvironmentConfigName ${{ parameters.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreBusiness:$true' + arguments: '-EnvironmentConfigName ${{ variables.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreBusiness:$true' continueOnError: false # Restore HTML @@ -168,7 +157,7 @@ stages: pwsh: false targetType: filePath filePath: '.\BackupRestoreTools\DeploymentTools\SystemRestore.ps1' - arguments: '-EnvironmentConfigName ${{ parameters.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreUIHtml:$true -doNotStopHosts:$true' + arguments: '-EnvironmentConfigName ${{ variables.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreUIHtml:$true -doNotStopHosts:$true' continueOnError: false # Restore Help @@ -178,7 +167,7 @@ stages: pwsh: false targetType: filePath filePath: '.\BackupRestoreTools\DeploymentTools\SystemRestore.ps1' - arguments: '-EnvironmentConfigName ${{ parameters.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreUIHelp:$true -doNotStopHosts:$true' + arguments: '-EnvironmentConfigName ${{ variables.EnvironmentConfigName }} -InteractiveMode:$false -restoreIdentifier "$(RestoreIdentifier)" -FullRestore:$false -RestoreUIHelp:$true -doNotStopHosts:$true' continueOnError: false # Clean @@ -263,7 +252,7 @@ stages: displayName: 'Copy EnvironmentConfig to Server' inputs: SourceFolder: Configurations/EnvironmentConfigs - Contents: '${{ parameters.EnvironmentConfigName }}' + Contents: '${{ variables.EnvironmentConfigName }}' TargetFolder: ${{ variables.CandidatePackages }} # Customization Installation @@ -271,11 +260,11 @@ stages: displayName: "Customization Installation" inputs: pwsh: false - arguments: "-ImagePath '${{ variables.ISOImagePath }}' -EnvironmentConfigName '${{ parameters.EnvironmentConfigName }}' -PackageSource '${{ variables.CandidatePackages }}'" + arguments: "-ImagePath '${{ variables.ISOImagePath }}' -EnvironmentConfigName '${{ variables.EnvironmentConfigName }}' -PackageSource '${{ variables.CandidatePackages }}'" targetType: 'inline' script: | $ImagePath = '${{ variables.ISOImagePath }}'; - $EnvironmentConfigName = '${{ parameters.EnvironmentConfigName }}'; + $EnvironmentConfigName = '${{ variables.EnvironmentConfigName }}'; $PackageSource = '${{ variables.CandidatePackages }}'; # Assuming repository Checkout @@ -401,7 +390,7 @@ stages: displayName: 'Copy EnvironmentConfig to BackupRestoreTools' inputs: SourceFolder: Configurations/EnvironmentConfigs - Contents: '${{ parameters.EnvironmentConfigName }}' + Contents: '${{ variables.EnvironmentConfigName }}' TargetFolder: BackupRestoreTools/EnvironmentConfigs # Create Restore Point @@ -411,7 +400,7 @@ stages: pwsh: false targetType: filePath filePath: './BackupRestoreTools/DeploymentTools/SystemBackup.ps1' - arguments: "-EnvironmentConfigName ${{ parameters.EnvironmentConfigName }} -backupIdentifier $(GetPackageVersion.PackageId)_$(GetPackageVersion.PackageVersion) -InteractiveMode:$false" + arguments: "-EnvironmentConfigName ${{ variables.EnvironmentConfigName }} -backupIdentifier $(GetPackageVersion.PackageId)_$(GetPackageVersion.PackageVersion) -InteractiveMode:$false" continueOnError: false # Clean @@ -475,10 +464,10 @@ stages: # Copy EnvironmentConfig to Server - task: CopyFiles@2 - displayName: 'Copy ${{ parameters.EnvironmentConfigName }} to ${{ variables.CandidatePackages }}' + displayName: 'Copy ${{ variables.EnvironmentConfigName }} to ${{ variables.CandidatePackages }}' inputs: SourceFolder: Configurations/EnvironmentConfigs - Contents: '${{ parameters.EnvironmentConfigName }}' + Contents: '${{ variables.EnvironmentConfigName }}' TargetFolder: ${{ variables.CandidatePackages }} condition: eq(variables['ArtifactExists'], true) @@ -487,11 +476,11 @@ stages: displayName: "Load Master Data Files" inputs: pwsh: false - arguments: "-ImagePath '${{ variables.ISOImagePath }}' -EnvironmentConfigName '${{ parameters.EnvironmentConfigName }}' -PackageSource '${{ variables.CandidatePackages }}'" + arguments: "-ImagePath '${{ variables.ISOImagePath }}' -EnvironmentConfigName '${{ variables.EnvironmentConfigName }}' -PackageSource '${{ variables.CandidatePackages }}'" targetType: 'inline' script: | $ImagePath = '${{ variables.ISOImagePath }}'; - $EnvironmentConfigName = '${{ parameters.EnvironmentConfigName }}'; + $EnvironmentConfigName = '${{ variables.EnvironmentConfigName }}'; $PackageSource = '${{ variables.CandidatePackages }}'; # Assuming repository Checkout @@ -611,7 +600,7 @@ stages: displayName: 'Copy EnvironmentConfig to BackupRestoreTools' inputs: SourceFolder: Configurations/EnvironmentConfigs - Contents: '${{ parameters.EnvironmentConfigName }}' + Contents: '${{ variables.EnvironmentConfigName }}' TargetFolder: BackupRestoreTools/EnvironmentConfigs # Create Restore Point - DailyBackup @@ -621,7 +610,7 @@ stages: pwsh: false targetType: filePath filePath: './BackupRestoreTools/DeploymentTools/SystemBackup.ps1' - arguments: "-EnvironmentConfigName ${{ parameters.EnvironmentConfigName }} -backupIdentifier 'DailyBackup' -InteractiveMode:$false -FullBackup:$false -BackupDBOnline:$true -doNotStopHosts:$true" + arguments: "-EnvironmentConfigName ${{ variables.EnvironmentConfigName }} -backupIdentifier 'DailyBackup' -InteractiveMode:$false -FullBackup:$false -BackupDBOnline:$true -doNotStopHosts:$true" continueOnError: false # Clean @@ -725,7 +714,7 @@ stages: testAssemblyVer2: '**\*.Biz.dll' searchFolder: $(System.DefaultWorkingDirectory) resultsFolder: '$(Agent.TempDirectory)\TestResults' - runSettingsFile: 'TestExecution\RunSettings\${{ parameters.RunSettings }}' + runSettingsFile: 'TestExecution\RunSettings\${{ variables.RunSettings }}' testRunTitle: "Business Tests" rerunFailedTests: true rerunType: "basedOnTestFailurePercentage" # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount @@ -741,7 +730,7 @@ stages: testAssemblyVer2: '**\*.GUI.dll' searchFolder: $(System.DefaultWorkingDirectory) resultsFolder: '$(Agent.TempDirectory)\TestResults' - runSettingsFile: 'TestExecution\RunSettings\${{ parameters.RunSettings }}' + runSettingsFile: 'TestExecution\RunSettings\${{ variables.RunSettings }}' testRunTitle: "HTML Tests" rerunFailedTests: true rerunType: "basedOnTestFailurePercentage" # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount @@ -758,7 +747,7 @@ stages: searchFolder: $(System.DefaultWorkingDirectory) resultsFolder: '$(Agent.TempDirectory)\TestResults' platform: latest - runSettingsFile: 'TestExecution\RunSettings\${{ parameters.RunSettings }}' + runSettingsFile: 'TestExecution\RunSettings\${{ variables.RunSettings }}' testRunTitle: "IoT Tests" rerunFailedTests: true rerunType: "basedOnTestFailurePercentage" # Optional. Options: basedOnTestFailurePercentage, basedOnTestFailureCount @@ -944,7 +933,7 @@ stages: targetType: inline failOnStderr: true script: | - $EnvironmentConfig = "${{ parameters.EnvironmentConfigName }}"; + $EnvironmentConfig = "${{ variables.EnvironmentConfigName }}"; $EnvConfigFile = Get-Item "./Configurations/EnvironmentConfigs/$EnvironmentConfig" $EnvConfigJson = Get-Content -Raw -Path $EnvConfigFile | ConvertFrom-Json $BackupLocation = $EnvConfigJson.'Product.Database.BackupShare' diff --git a/cmf-cli/resources/template_feed/init/EnvironmentConfigs/%EnvironmentName%.yml b/cmf-cli/resources/template_feed/init/EnvironmentConfigs/%EnvironmentName%.yml new file mode 100644 index 00000000..5faa66f1 --- /dev/null +++ b/cmf-cli/resources/template_feed/init/EnvironmentConfigs/%EnvironmentName%.yml @@ -0,0 +1,31 @@ +variables: + # Environment Config file name exported from DevOpsCenter + EnvironmentConfigName: '<%= $CLI_PARAM_ReleaseEnvironmentConfig %>' + + # Run Settings + RunSettings: 'integration.runsettings' + +//#if (releaseCustomerEnvironment != "") { + # Customer Environment Name defined in DevOpsCenter + CustomerEnvironmentName: '<%= $CLI_PARAM_ReleaseCustomerEnvironment %>' +//#endif + +//#if (releaseSite != "") { + # Site + SiteName: '<%= $CLI_PARAM_ReleaseSite %>' +//#endif + +//#if (releaseDeploymentPackage != "") { + # Deployment Package + DeploymentPackage: '<%= $CLI_PARAM_ReleaseDeploymentPackage %>' +//#endif + +//#if (releaseLicense != "") { + # License + LicenseName: '<%= $CLI_PARAM_ReleaseLicense %>' +//#endif + +//#if (releaseDeploymentTarget != "") { + # Deployment Target + DeploymentTarget: '<%= $CLI_PARAM_ReleaseDeploymentTarget %>' +//#endif diff --git a/cmf-cli/resources/template_feed/init/EnvironmentConfigs/GlobalVariables.yml b/cmf-cli/resources/template_feed/init/EnvironmentConfigs/GlobalVariables.yml index 45e6497e..be78c519 100644 --- a/cmf-cli/resources/template_feed/init/EnvironmentConfigs/GlobalVariables.yml +++ b/cmf-cli/resources/template_feed/init/EnvironmentConfigs/GlobalVariables.yml @@ -16,7 +16,7 @@ variables: # cmf pipeline Version CmfPipelineVersion: '1.x.x' # Iso Image Path - ISOImagePath: '<%= $CLI_PARAM_ISOLocation %>\v<%= $CLI_PARAM_MESVersion-Feature %>\Critical Manufacturing <%= $CLI_PARAM_MESVersion %>.iso' + ISOImagePath: '<%= $CLI_PARAM_ISOLocation %>' # Current refspec to get the tools for the package (by default, a tagged MES version release) CommonBranch: 'refs/tags/<%= $CLI_PARAM_MESVersion %>' # Node version to use in the pipelines From bf67dbc58045845e34e650084d2525c7428812af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Tue, 4 Jan 2022 13:41:53 +0000 Subject: [PATCH 2/5] chore(init): add support for new options --- cmf-cli/Commands/init/InitCommand.cs | 85 +++++++++++--- .../init/.template.config/template.json | 30 +++++ .../Tests.Package/integration.runsettings | 2 +- .../test/Tests.Package/local.runsettings | 2 +- tests/Specs/CmfPackage_Load.cs | 2 +- tests/Specs/New.cs | 111 ++++++++++++++++++ 6 files changed, 213 insertions(+), 19 deletions(-) diff --git a/cmf-cli/Commands/init/InitCommand.cs b/cmf-cli/Commands/init/InitCommand.cs index 3729525d..f9e1bd74 100644 --- a/cmf-cli/Commands/init/InitCommand.cs +++ b/cmf-cli/Commands/init/InitCommand.cs @@ -16,7 +16,7 @@ namespace Cmf.Common.Cli.Commands public enum AgentType { /// - /// Cloud agents + /// Cloud agents /// Cloud, /// @@ -24,7 +24,7 @@ public enum AgentType /// 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 @@ -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 } @@ -149,7 +154,7 @@ public override void Configure(Command cmd) aliases: new[] { "--testScenariosNugetVersion" }, description: "Test Scenarios Nuget Version" )); - + // infra options cmd.AddOption(new Option( aliases: new[] { "--infra", "--infrastructure" }, @@ -191,6 +196,26 @@ public override void Configure(Command cmd) aliases: new[] { "--nugetRegistryPassword" }, description: "NuGet registry password" )); + cmd.AddOption(new Option( + aliases: new[] { "--releaseCustomerEnvironment" }, + description: "Customer Environment Name defined in DevOpsCenter" + )); + cmd.AddOption(new Option( + aliases: new[] { "--releaseSite" }, + description: "Site defined in DevOpsCenter" + )); + cmd.AddOption(new Option( + aliases: new[] { "--releaseDeploymentPackage" }, + description: "DeploymentPackage defined in DevOpsCenter" + )); + cmd.AddOption(new Option( + aliases: new[] { "--releaseLicense" }, + description: "License defined in DevOpsCenter" + )); + cmd.AddOption(new Option( + aliases: new[] { "--releaseDeploymentTarget" }, + description: "DeploymentTarget defined in DevOpsCenter" + )); // Add the handler cmd.Handler = CommandHandler @@ -228,7 +253,7 @@ internal void Execute(InitArguments x) { // engine options "--output", x.workingDir.FullName, - + // template symbols "--customPackageName", x.rootPackageName, "--projectName", x.projectName @@ -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}); @@ -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}); @@ -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); @@ -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(infraJson["AgentType"]?.Value, out AgentType agentTypeParsed)) { - x.agentType ??= agentTypeParsed; + x.agentType ??= agentTypeParsed; } if (!string.IsNullOrEmpty(infraJson["NuGetRegistryUsername"]?.Value)) { @@ -325,7 +346,7 @@ internal void Execute(InitArguments x) } } } - + if (x.nugetRegistry != null) { args.AddRange(new [] {"--nugetRegistry", x.nugetRegistry.AbsoluteUri}); @@ -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)); } } diff --git a/cmf-cli/resources/template_feed/init/.template.config/template.json b/cmf-cli/resources/template_feed/init/.template.config/template.json index a31a740c..0599adb1 100644 --- a/cmf-cli/resources/template_feed/init/.template.config/template.json +++ b/cmf-cli/resources/template_feed/init/.template.config/template.json @@ -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": { diff --git a/cmf-cli/resources/template_feed/test/Tests.Package/integration.runsettings b/cmf-cli/resources/template_feed/test/Tests.Package/integration.runsettings index d76dcb5b..1929d615 100644 --- a/cmf-cli/resources/template_feed/test/Tests.Package/integration.runsettings +++ b/cmf-cli/resources/template_feed/test/Tests.Package/integration.runsettings @@ -22,7 +22,7 @@ - + diff --git a/cmf-cli/resources/template_feed/test/Tests.Package/local.runsettings b/cmf-cli/resources/template_feed/test/Tests.Package/local.runsettings index 2ff192ca..ed7d61a6 100644 --- a/cmf-cli/resources/template_feed/test/Tests.Package/local.runsettings +++ b/cmf-cli/resources/template_feed/test/Tests.Package/local.runsettings @@ -22,7 +22,7 @@ - + diff --git a/tests/Specs/CmfPackage_Load.cs b/tests/Specs/CmfPackage_Load.cs index a0c7a332..09be5117 100644 --- a/tests/Specs/CmfPackage_Load.cs +++ b/tests/Specs/CmfPackage_Load.cs @@ -9,7 +9,7 @@ using System.Text; using System.Threading.Tasks; -namespace tests.Specs +namespace tests { [TestClass] public class CmfPackage_Load diff --git a/tests/Specs/New.cs b/tests/Specs/New.cs index bc8392d9..bd8d5fbe 100644 --- a/tests/Specs/New.cs +++ b/tests/Specs/New.cs @@ -138,5 +138,116 @@ public void Init() Directory.Delete(tmp, true); } } + + [TestMethod] + public void Init_Containers() + { + var initCommand = new InitCommand(); + var cmd = new Command("x"); + initCommand.Configure(cmd); + + var rnd = new Random(); + var tmp = Path.Join(Path.GetTempPath(), Convert.ToHexString(Guid.NewGuid().ToByteArray()).Substring(0, 8)); + Directory.CreateDirectory(tmp); + + Debug.WriteLine("Generating at " + tmp); + + var projectName = Convert.ToHexString(Guid.NewGuid().ToByteArray()).Substring(0, 8); + var repoUrl = "https://repo_url/collection/project/_git/repo"; + var deploymentDir = "\\\\share\\deployment_dir"; + var isoLocation = "\\\\share\\iso_location"; + var pkgVersion = $"{rnd.Next(10)}.{rnd.Next(10)}.{rnd.Next(10)}"; + + var cur = Directory.GetCurrentDirectory(); + try + { + var console = new TestConsole(); + Directory.SetCurrentDirectory(tmp); + cmd.Invoke(new[] + { + projectName, + "--infra", this.GetFixturePath("init", "infrastructure.json"), + "-c", this.GetFixturePath("init", "config.json"), + "--repositoryUrl", repoUrl, + "--MESVersion", "8.2.0", + "--DevTasksVersion", "8.1.0", + "--HTMLStarterVersion", "8.0.0", + "--yoGeneratorVersion", "8.1.0", + "--nugetVersion", "8.2.0", + "--testScenariosNugetVersion", "8.2.0", + "--deploymentDir", deploymentDir, + "--ISOLocation", isoLocation, + "--version", pkgVersion, + "--releaseCustomerEnvironment", "cmf-environment", + "--releaseSite", "cmf-site", + "--releaseDeploymentPackage", @"\@criticalmanufacturing\mes:8.3.1", + "--releaseLicense", "cmf-license", + "--releaseDeploymentTarget", "cmf-target", + tmp + }, console); + + var extractFileName = new Func(s => s.Split(Path.DirectorySeparatorChar).LastOrDefault()); + + Assert.IsTrue(File.Exists(".project-config.json"), "project config is missing"); + Assert.IsTrue(File.Exists("cmfpackage.json"), "root cmfpackage is missing"); + Assert.IsTrue(File.Exists("global.json"), "global .NET versioning is missing"); + Assert.IsTrue(File.Exists("NuGet.Config"), "global NuGet feeds config is missing"); + + Assert.IsTrue(Directory.Exists(Path.Join(tmp, "Builds")), "pipelines are missing"); + Assert.IsTrue( + new[]{ "CI-Changes.json", + "CI-Package.json", + "CI-Publish.json", + "CI-Release.json", + "PR-Changes.json", + "PR-Package.json" } + .ToList() + .All(f => Directory + .GetFiles("Builds") + .Select(extractFileName) + .Contains(f)), "Missing pipeline metadata"); + Assert.IsTrue( + new[]{ "CI-Changes.yml", + "CI-Package.yml", + "CI-Publish.yml", + "CI-Release.yml", + "PR-Changes.yml", + "PR-Package.yml" } + .ToList() + .All(f => Directory + .GetFiles("Builds") + .Select(extractFileName) + .Contains(f)), "Missing pipeline source"); + Assert.IsTrue( + new[]{ "policies-master.json", + "policies-development.json" } + .ToList() + .All(f => Directory + .GetFiles("Builds") + .Select(extractFileName) + .Contains(f)), "Missing policy metadata"); + Assert.IsTrue(Directory.Exists(Path.Join(tmp, "EnvironmentConfigs")), "environment configs are missing"); + Assert.IsTrue( + new[] { "GlobalVariables.yml" } + .ToList() + .All(f => Directory + .GetFiles("EnvironmentConfigs") + .Select(extractFileName) + .Contains(f)), "Missing global variables"); + Assert.IsTrue( + new[] { "config.json" } // this should be a constant when moving to a mock + .ToList() + .All(f => Directory + .GetFiles("EnvironmentConfigs") + .Select(extractFileName) + .Contains(f)), "Missing environment configuration"); + Assert.IsTrue(Directory.Exists(Path.Join(tmp, "Libs")), "Libs are missing"); + } + finally + { + Directory.SetCurrentDirectory(cur); + Directory.Delete(tmp, true); + } + } } } \ No newline at end of file From 9236c4e3f73ffea6342300febfb54134eebd12c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Wed, 5 Jan 2022 09:09:47 +0000 Subject: [PATCH 3/5] fix(pipeline): add missing trigger --- .../template_feed/init/Builds/CD-Containers.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json index 159e1a3b..b5b1a281 100644 --- a/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json +++ b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.json @@ -29,7 +29,16 @@ "inputs": {} } ], - "triggers": [], + "triggers": [ + { + "branchFilters": [], + "pathFilters": [], + "settingsSourceType": 2, + "batchChanges": false, + "maxConcurrentBuildsPerBranch": 1, + "triggerType": 2 + } + ], "properties": {}, "tags": [], "jobAuthorizationScope": 1, From d60cdbe73b74ea10705c2b4daed00ad7fbb79b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Wed, 5 Jan 2022 11:55:07 +0000 Subject: [PATCH 4/5] chore: ignore .history folder --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f4032682..8dcd0c9a 100644 --- a/.gitignore +++ b/.gitignore @@ -354,4 +354,7 @@ dist/ launchSettings.json !**/Commands/publish -*.orig +*.orig + +# xyz.local-history vscode extension +.history/** \ No newline at end of file From a0ac70b8f686776f4f5eb5b53c3e3c80fc3f7021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Wed, 5 Jan 2022 11:55:45 +0000 Subject: [PATCH 5/5] fix: pullrequest comments --- .../template_feed/init/Builds/CD-Containers.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml index 5ebc8d59..2268d010 100644 --- a/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml +++ b/cmf-cli/resources/template_feed/init/Builds/CD-Containers.yml @@ -296,11 +296,6 @@ stages: $envConfig = Get-Content "$file" | out-string | ConvertFrom-Json $envConfig.ENV_MANAGER_BOOT_PACKAGE = $PackageIdentifier - $packageSourceShare = "$(CandidatePackages)/Package" - $addrPackageSourceShare = (($packageSourceShare -split "\\" | Where { $_ -ne "" })[0] -replace ".cmf.criticalmanufacturing.com") - $envConfig.DockerSwarm_Volume_NetworkShare_Path_package_source_share = $packageSourceShare; - $envConfig.DockerSwarm_Volume_NetworkShare_Address_package_source_share = "$addrPackageSourceShare.cmf.criticalmanufacturing.com" - Write-Output "Installing package $PackageIdentifier" $envConfig | ConvertTo-Json -Depth 10 | set-content "$(Agent.TempDirectory)/install-package.json" @@ -539,6 +534,7 @@ stages: pwsh: true workingDirectory: 'C:\tools\Cmf.Deployment.Framework' + condition: eq(variables['ArtifactExists'], true) # Clean - task: PostBuildCleanup@3 @@ -893,11 +889,11 @@ stages: condition: always() - stage: "SetNewRestorePoint" - displayName: "Copy Full Backup packages to stack packages share" + displayName: "Copy Full Backup packages to approved packages share" condition: or( and( eq('${{ variables.SetNewRestorePoint }}', true), eq('${{ parameters.ExecuteAllStages }}', true), succeeded() ), and( eq('${{ parameters.ExecuteAllStages }}', false), eq('${{ parameters.SetNewRestorePoint }}', true) ) ) jobs: - job: "SetNewRestorePoint" - displayName: "Copy Full Backup packages to stack packages share" + displayName: "Copy Full Backup packages to approved packages share" workspace: clean: all steps: