mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-10 03:13:23 +00:00
Configure CI to get tool versions
This commit is contained in:
@@ -56,6 +56,15 @@ class AzureDevOpsApi
|
|||||||
return $this.InvokeRestMethod($url, 'GET', $null)
|
return $this.InvokeRestMethod($url, 'GET', $null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[object] UpdateBuildStatus([UInt32]$BuildId, [string]$BuildStatus){
|
||||||
|
$url = "build/builds/$BuildId"
|
||||||
|
$body = @{
|
||||||
|
status = $BuildStatus
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
return $this.InvokeRestMethod($url, 'PATCH', $body)
|
||||||
|
}
|
||||||
|
|
||||||
[string] hidden BuildUrl([string]$Url) {
|
[string] hidden BuildUrl([string]$Url) {
|
||||||
return "$($this.BaseUrl)/${Url}/?api-version=5.1"
|
return "$($this.BaseUrl)/${Url}/?api-version=5.1"
|
||||||
}
|
}
|
||||||
|
|||||||
32
azure-pipelines/get-tool-versions.yml
Normal file
32
azure-pipelines/get-tool-versions.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: $(date:yyyyMMdd)$(rev:.r)
|
||||||
|
trigger: none
|
||||||
|
pr: none
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- stage: Get_New_Versions
|
||||||
|
dependsOn: []
|
||||||
|
jobs:
|
||||||
|
- job: Get_Tool_Versions
|
||||||
|
timeoutInMinutes: 30
|
||||||
|
pool:
|
||||||
|
name: Azure Pipelines
|
||||||
|
vmImage: 'ubuntu-18.04'
|
||||||
|
steps:
|
||||||
|
- template: /azure-pipelines/templates/get-tool-versions-steps.yml
|
||||||
|
|
||||||
|
- stage: Trigger_Builds
|
||||||
|
dependsOn: Get_New_Versions
|
||||||
|
jobs:
|
||||||
|
- deployment: Run_Builds
|
||||||
|
pool:
|
||||||
|
name: Azure Pipelines
|
||||||
|
vmImage: 'ubuntu-18.04'
|
||||||
|
variables:
|
||||||
|
ToolVersions: $[ stageDependencies.Get_New_Versions.Get_Tool_Versions.outputs['Get_versions.TOOL_VERSIONS'] ]
|
||||||
|
timeoutInMinutes: 180
|
||||||
|
environment: 'Get Available Tools Versions - Publishing Approval'
|
||||||
|
strategy:
|
||||||
|
runOnce:
|
||||||
|
deploy:
|
||||||
|
steps:
|
||||||
|
- template: /azure-pipelines/templates/run-ci-builds-steps.yml
|
||||||
53
azure-pipelines/templates/get-tool-versions-steps.yml
Normal file
53
azure-pipelines/templates/get-tool-versions-steps.yml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
steps:
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Get new versions'
|
||||||
|
name: 'Get_versions'
|
||||||
|
inputs:
|
||||||
|
targetType: filePath
|
||||||
|
filePath: './get-new-tool-versions/get-new-tool-versions.ps1'
|
||||||
|
arguments: |
|
||||||
|
-DistURL "$(DIST_URL)" `
|
||||||
|
-ManifestLink "$(MANIFEST_URL)" `
|
||||||
|
-VersionFilterToInclude $(INCLUDE_FILTER) `
|
||||||
|
-VersionFilterToExclude $(EXCLUDE_FILTER) `
|
||||||
|
-RetryIntervalSec $(INTERVAL_SEC) `
|
||||||
|
-RetryCount $(RETRY_COUNT)
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Cancel build'
|
||||||
|
condition: and(succeeded(), eq(variables['Get_versions.TOOL_VERSIONS'], ''))
|
||||||
|
inputs:
|
||||||
|
TargetType: inline
|
||||||
|
script: |
|
||||||
|
Import-Module "./azure-devops/azure-devops-api.ps1"
|
||||||
|
$azureDevOpsApi = Get-AzureDevOpsApi -TeamFoundationCollectionUri $(System.TeamFoundationCollectionUri) `
|
||||||
|
-ProjectName $(System.TeamProject) `
|
||||||
|
-AccessToken $(System.AccessToken) `
|
||||||
|
-RetryCount $(INTERVAL_SEC) `
|
||||||
|
-RetryIntervalSec $(RETRY_COUNT)
|
||||||
|
|
||||||
|
$AzureDevOpsApi.UpdateBuildStatus($(Build.BuildId), 'Cancelling') | Out-Null
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Set env variables'
|
||||||
|
condition: and(succeeded(), ne(variables['Get_versions.TOOL_VERSIONS'], ''))
|
||||||
|
inputs:
|
||||||
|
TargetType: inline
|
||||||
|
script: |
|
||||||
|
$PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)"
|
||||||
|
Write-Output "##vso[task.setvariable variable=PIPELINE_URL]$PipelineUrl"
|
||||||
|
$toolVersion = "$(Get_versions.TOOL_VERSIONS)".Replace(",",", ")
|
||||||
|
Write-Output "##vso[task.setvariable variable=TOOL_VERSIONS]$toolVersion"
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Send Slack notification'
|
||||||
|
condition: and(succeeded(), ne(variables['Get_versions.TOOL_VERSIONS'], ''))
|
||||||
|
inputs:
|
||||||
|
targetType: filePath
|
||||||
|
filePath: './get-new-tool-versions/send-slack-notification.ps1'
|
||||||
|
arguments: |
|
||||||
|
-Url "$(SLACK_CHANNEL_URL)" `
|
||||||
|
-ToolName "$(TOOL_NAME)" `
|
||||||
|
-ToolVersion "$(TOOL_VERSIONS)" `
|
||||||
|
-PipelineUrl "$(PIPELINE_URL)" `
|
||||||
|
-ImageUrl "$(IMAGE_URL)"
|
||||||
29
azure-pipelines/templates/run-ci-builds-steps.yml
Normal file
29
azure-pipelines/templates/run-ci-builds-steps.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
steps:
|
||||||
|
- checkout: self
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Get source version'
|
||||||
|
inputs:
|
||||||
|
TargetType: inline
|
||||||
|
script: |
|
||||||
|
$url = "https://api.github.com/repos/$(REPOSITORY)/commits/$(BRANCH)"
|
||||||
|
$commit = Invoke-RestMethod -Uri $url -Method "GET"
|
||||||
|
Write-Output "##vso[task.setvariable variable=COMMIT_SHA]$($commit.sha)"
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: 'Run builds'
|
||||||
|
inputs:
|
||||||
|
targetType: filePath
|
||||||
|
filePath: './azure-devops/run-ci-builds.ps1'
|
||||||
|
arguments: |
|
||||||
|
-TeamFoundationCollectionUri $(System.TeamFoundationCollectionUri) `
|
||||||
|
-AzureDevOpsProjectName $(System.TeamProject) `
|
||||||
|
-AzureDevOpsAccessToken $(System.AccessToken) `
|
||||||
|
-SourceBranch $(BRANCH) `
|
||||||
|
-DefinitionId $(DEFINITION_ID) `
|
||||||
|
-SourceVersion $(COMMIT_SHA) `
|
||||||
|
-ManifestLink $(MANIFEST_LINK) `
|
||||||
|
-WaitForBuilds $(WAIT_FOR_BUILDS) `
|
||||||
|
-ToolVersions "$(ToolVersions)" `
|
||||||
|
-RetryIntervalSec $(INTERVAL_SEC) `
|
||||||
|
-RetryCount $(RETRY_COUNT)
|
||||||
@@ -73,7 +73,7 @@ $versionsToBuild = Skip-ExistingVersions -VersionsFromManifest $versionsFromMani
|
|||||||
if ($versionsToBuild) {
|
if ($versionsToBuild) {
|
||||||
$availableVersions = $versionsToBuild -join ","
|
$availableVersions = $versionsToBuild -join ","
|
||||||
Write-Host "The following versions are available to build:`n$availableVersions"
|
Write-Host "The following versions are available to build:`n$availableVersions"
|
||||||
Write-Output "##vso[task.setvariable variable=TOOL_VERSIONS]$availableVersions"
|
Write-Output "##vso[task.setvariable variable=TOOL_VERSIONS;isOutput=true]$availableVersions"
|
||||||
} else {
|
} else {
|
||||||
Write-Host "There aren't versions to build"
|
Write-Host "There aren't versions to build"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user