diff --git a/.azure-pipelines/build-job.yml b/.azure-pipelines/build-job.yml index 050fc70709..9fa0770bbc 100644 --- a/.azure-pipelines/build-job.yml +++ b/.azure-pipelines/build-job.yml @@ -86,6 +86,7 @@ jobs: DisableCFSDetector: true DisableDockerDetector: true nugetMultiFeedWarnLevel: none + CheckoutBranch: ${{ parameters.branch }} steps: @@ -102,7 +103,7 @@ jobs: - ${{ if ne(parameters.branch, '') }}: - template: switch-branch.yml parameters: - branch: ${{ parameters.branch }} + branch: $(CheckoutBranch) # 1ES images used on the ARM pool doesn't contain unzip tool, so we need to install it before starting the build - ${{ if and(eq(parameters.arch, 'arm64'), ne(parameters.os, 'osx')) }}: @@ -119,7 +120,7 @@ jobs: ADO_ENABLE_LOGISSUE: true # Check if broken symlinks exist in the agent build - - task: Bash@3.201.1 + - task: Bash@3 inputs: filePath: src/Misc/check-symlinks.sh displayName: Check symlinks @@ -255,4 +256,4 @@ jobs: inputs: CodesignValidation: true CodesignValidationBreakOn: WarningAbove - ToolLogsNotFoundAction: Error + ToolLogsNotFoundAction: Error \ No newline at end of file diff --git a/.azure-pipelines/build-jobs.yml b/.azure-pipelines/build-jobs.yml index 594239c308..b198a74294 100644 --- a/.azure-pipelines/build-jobs.yml +++ b/.azure-pipelines/build-jobs.yml @@ -98,4 +98,4 @@ jobs: sign: ${{ parameters.sign }} verifySigning: ${{ parameters.verifySigning }} publishArtifact: ${{ parameters.publishArtifacts }} - packageType: pipelines-agent + packageType: pipelines-agent \ No newline at end of file diff --git a/.azure-pipelines/pipeline.yml b/.azure-pipelines/pipeline.yml index a0a5a40be0..6ddf88e6d3 100644 --- a/.azure-pipelines/pipeline.yml +++ b/.azure-pipelines/pipeline.yml @@ -26,6 +26,12 @@ parameters: - name: testProxyAgent type: boolean default: false +- name: stageDependencies + type: object + default: [] +- name: stageCondition + type: string + default: '' # Targets - name: win_x64 @@ -64,6 +70,10 @@ stages: - stage: build displayName: Build + ${{ if ne(length(parameters.stageDependencies), 0)}}: + dependsOn: ${{ parameters.stageDependencies }} + ${{ if ne(parameters.stageCondition, '') }}: + condition: ${{ parameters.stageCondition }} jobs: # Test Proxy Agent - ${{ if parameters.testProxyAgent }}: diff --git a/.azure-pipelines/switch-branch.yml b/.azure-pipelines/switch-branch.yml index 9f4178c316..4ae014f5f0 100644 --- a/.azure-pipelines/switch-branch.yml +++ b/.azure-pipelines/switch-branch.yml @@ -4,8 +4,11 @@ parameters: steps: - ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: - - script: | + - pwsh: | git config user.email "azure-pipelines-bot@microsoft.com" git config user.name "azure-pipelines-bot" - git checkout -f origin/${{ parameters.branch }} + + git checkout -f origin/$env:BRANCH_NAME displayName: Checkout branch + env: + BRANCH_NAME: ${{ parameters.branch }} diff --git a/.vsts.release.yml b/.vsts.release.yml index b2e07ba0cb..1135e2fce7 100644 --- a/.vsts.release.yml +++ b/.vsts.release.yml @@ -1,7 +1,15 @@ +schedules: +- cron: '0 6 * * 2' + displayName: Scheduled weekly run + branches: + include: + - master + parameters: - name: version type: string displayName: Version + default: '3.999.999' - name: derivedFrom type: string displayName: Derived From Version @@ -27,54 +35,105 @@ parameters: default: true displayName: Test Proxy Agent -variables: - ${{ if parameters.buildStageOnly }}: - releaseBranch: '' - ${{ else }}: - releaseBranch: releases/${{ parameters.version }} - extends: template: .azure-pipelines/pipeline.yml parameters: - branch: ${{ variables.releaseBranch }} + branch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ] componentDetection: false test: ${{ not(parameters.skipTests) }} sign: true publishArtifacts: true testProxyAgent: ${{ parameters.testProxyAgent }} + stageDependencies: + - Verify_release + - Create_Release_Branch + stageCondition: | + and( + succeeded('Verify_release'), + in(dependencies.Create_Release_Branch.result, 'Succeeded', 'Skipped') + ) preBuildStages: - - ${{ if and(not(parameters.buildStageOnly), eq(variables['Build.SourceBranch'], 'refs/heads/master')) }}: - - stage: Create_Release_Branch + - stage: Verify_release + displayName: Make sure it's actually the release run + pool: + vmImage: ubuntu-latest + jobs: + - job: Set_variables + displayName: Set release-specific variables + steps: + - pwsh: | + $isBuildStageOnly = [System.Convert]::ToBoolean('${{ parameters.buildStageOnly }}') + $buildReason = '$(Build.Reason)' + + $currentSprint = (Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept" = "application/json" } | ConvertFrom-Json) + $isReleaseWeek = $currentSprint.week -eq 3 + Write-Host "isReleaseWeek = $isReleaseWeek" + + $isRelease = ($buildReason -eq 'Manual' -and !$isBuildStageOnly) -or ($buildReason -eq 'Schedule' -and !$isReleaseWeek) + Write-Host "isRelease = $isRelease" + Write-Host "##vso[task.setVariable variable=isRelease;isOutput=true]$isRelease" + + $isScheduledRelease = $isRelease -and $buildReason -eq 'Schedule' + Write-Host "isScheduledRelease = $isScheduledRelease" + + if ($isRelease) { + if ($isScheduledRelease) { + $agentVersion = "3.$($currentSprint.sprint).0" + } else { + $agentVersion = "${{ parameters.version }}" + } + Write-Host "agentVersion = $agentVersion" + Write-Host "##vso[task.setVariable variable=agentVersion;isOutput=true]$agentVersion" + + $releaseBranch = "releases/$agentVersion" + Write-Host "releaseBranch = $releaseBranch" + Write-Host "##vso[task.setVariable variable=releaseBranch;isOutput=true]$releaseBranch" + } + + name: SetReleaseVariables + displayName: Set release-specific variables + + - stage: Create_Release_Branch + displayName: Create Release Branch + dependsOn: + - Verify_release + jobs: + ################################################################################ + - job: Create_Release_Branch + ################################################################################ displayName: Create Release Branch - jobs: - ################################################################################ - - job: Create_Release_Branch - ################################################################################ - displayName: Create Release Branch - pool: - vmImage: ubuntu-latest + variables: + IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ] + ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ] + AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ] + condition: and(succeeded(), eq(variables.IsRelease, 'True')) + pool: + vmImage: ubuntu-latest + steps: - steps: - - checkout: self + - checkout: self - - task: NodeTool@0 - displayName: Use node 14.15.1 - inputs: - versionSpec: "14.15.1" + - task: NodeTool@0 + displayName: Use node 14.15.1 + inputs: + versionSpec: "14.15.1" - - script: | - cd release - npm install - node createReleaseBranch.js ${{ parameters.version }} --derivedFrom=${{ parameters.derivedFrom }} - env: - EDITOR: cat - PAT: $(GithubToken) - displayName: Push release branch to GitHub + - script: | + cd release + npm install + + node createReleaseBranch.js $(AgentVersion) --derivedFrom=${{ parameters.derivedFrom }} + env: + EDITOR: cat + PAT: $(GithubToken) + displayName: Push release branch to GitHub postBuildStages: - - ${{ if not(parameters.buildStageOnly) }}: - stage: Release + dependsOn: + - build + - Verify_release jobs: ################################################################################ - job: publish_agent_packages @@ -82,6 +141,10 @@ extends: displayName: Publish Agents (Windows/Linux/OSX) pool: name: RMAgentsProdAME + variables: + IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ] + ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ] + condition: and(succeeded(), eq(variables.IsRelease, 'True')) steps: # Clean @@ -91,7 +154,7 @@ extends: # Switch to release branch - template: switch-branch.yml parameters: - branch: ${{ variables.releaseBranch }} + branch: ${{ variables.ReleaseBranch }} # Download all agent packages from all previous phases - task: DownloadBuildArtifacts@0 @@ -178,38 +241,39 @@ extends: Invoke-RestMethod @assetsParams displayName: Create agent release on Github - - ${{ if not(parameters.onlyGitHubRelease) }}: - - stage: CreatePRs - jobs: - ################################################################################ - - job: create_ado_prs - ################################################################################ + - stage: CreatePRs + dependsOn: Release + condition: and(succeeded(), not(${{ parameters.onlyGitHubRelease }})) + jobs: + ################################################################################ + - job: create_ado_prs + ################################################################################ + displayName: Create PRs in AzureDevOps and ConfigChange + pool: + vmImage: ubuntu-latest + + steps: + - checkout: self + + - ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: + - script: git checkout ${{ variables.releaseBranch }} + displayName: Checkout release branch + + # Download all agent hashes created in previous phases + - task: DownloadBuildArtifacts@0 + displayName: Download Agent Hashes + inputs: + artifactName: hash + downloadPath: $(Build.SourcesDirectory)/_hashes + + - bash: | + set -x + cd release + npm install + ls + node createAdoPrs.js ${{ parameters.version }} displayName: Create PRs in AzureDevOps and ConfigChange - pool: - vmImage: ubuntu-latest - - steps: - - checkout: self - - - ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: - - script: git checkout ${{ variables.releaseBranch }} - displayName: Checkout release branch - - # Download all agent hashes created in previous phases - - task: DownloadBuildArtifacts@0 - displayName: Download Agent Hashes - inputs: - artifactName: hash - downloadPath: $(Build.SourcesDirectory)/_hashes - - - bash: | - set -x - cd release - npm install - ls - node createAdoPrs.js ${{ parameters.version }} - displayName: Create PRs in AzureDevOps and ConfigChange - env: - USERNAME: $(User) - PAT: $(AdoPAT) - USEREMAIL: $(Email) + env: + USERNAME: $(User) + PAT: $(AdoPAT) + USEREMAIL: $(Email) \ No newline at end of file