Remove AzDo related code
parent
33b79844a6
commit
fe999f6aa6
@ -1,108 +0,0 @@
|
|||||||
class AzureDevOpsApi
|
|
||||||
{
|
|
||||||
[string] $BaseUrl
|
|
||||||
[string] $RepoOwner
|
|
||||||
[object] $AuthHeader
|
|
||||||
[UInt32] $RetryCount
|
|
||||||
[UInt32] $RetryIntervalSec
|
|
||||||
|
|
||||||
AzureDevOpsApi(
|
|
||||||
[string] $TeamFoundationCollectionUri,
|
|
||||||
[string] $ProjectName,
|
|
||||||
[string] $AccessToken,
|
|
||||||
[UInt32] $RetryCount,
|
|
||||||
[UInt32] $RetryIntervalSec
|
|
||||||
) {
|
|
||||||
$this.BaseUrl = $this.BuildBaseUrl($TeamFoundationCollectionUri, $ProjectName)
|
|
||||||
$this.AuthHeader = $this.BuildAuth($AccessToken)
|
|
||||||
$this.RetryCount = $RetryCount
|
|
||||||
$this.RetryIntervalSec = $RetryIntervalSec
|
|
||||||
}
|
|
||||||
|
|
||||||
[object] hidden BuildAuth([string]$AccessToken) {
|
|
||||||
if ([string]::IsNullOrEmpty($AccessToken)) {
|
|
||||||
return $null
|
|
||||||
}
|
|
||||||
return @{
|
|
||||||
Authorization = "Bearer $AccessToken"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[string] hidden BuildBaseUrl([string]$TeamFoundationCollectionUri, [string]$ProjectName) {
|
|
||||||
return "${TeamFoundationCollectionUri}/${ProjectName}/_apis"
|
|
||||||
}
|
|
||||||
|
|
||||||
[object] QueueBuild([string]$ToolVersion, [string]$SourceBranch, [string]$SourceVersion, [UInt32]$DefinitionId){
|
|
||||||
$url = "build/builds"
|
|
||||||
|
|
||||||
# The content of parameters field should be a json string
|
|
||||||
$buildParameters = @{ VERSION = $ToolVersion } | ConvertTo-Json
|
|
||||||
|
|
||||||
$body = @{
|
|
||||||
definition = @{
|
|
||||||
id = $DefinitionId
|
|
||||||
}
|
|
||||||
sourceBranch = $SourceBranch
|
|
||||||
sourceVersion = $SourceVersion
|
|
||||||
parameters = $buildParameters
|
|
||||||
} | ConvertTo-Json
|
|
||||||
|
|
||||||
return $this.InvokeRestMethod($url, 'POST', $body)
|
|
||||||
}
|
|
||||||
|
|
||||||
[object] GetBuildInfo([UInt32]$BuildId){
|
|
||||||
$url = "build/builds/$BuildId"
|
|
||||||
|
|
||||||
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) {
|
|
||||||
return "$($this.BaseUrl)/${Url}/?api-version=5.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
[object] hidden InvokeRestMethod(
|
|
||||||
[string] $Url,
|
|
||||||
[string] $Method,
|
|
||||||
[string] $Body
|
|
||||||
) {
|
|
||||||
$requestUrl = $this.BuildUrl($Url)
|
|
||||||
$params = @{
|
|
||||||
Method = $Method
|
|
||||||
ContentType = "application/json"
|
|
||||||
Uri = $requestUrl
|
|
||||||
Headers = @{}
|
|
||||||
}
|
|
||||||
if ($this.AuthHeader) {
|
|
||||||
$params.Headers += $this.AuthHeader
|
|
||||||
}
|
|
||||||
if (![string]::IsNullOrEmpty($body)) {
|
|
||||||
$params.Body = $Body
|
|
||||||
}
|
|
||||||
|
|
||||||
$params.RetryIntervalSec = $this.RetryIntervalSec
|
|
||||||
$params.MaximumRetryCount = $this.RetryCount
|
|
||||||
|
|
||||||
return Invoke-RestMethod @params
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-AzureDevOpsApi {
|
|
||||||
param (
|
|
||||||
[string] $TeamFoundationCollectionUri,
|
|
||||||
[string] $ProjectName,
|
|
||||||
[string] $AccessToken,
|
|
||||||
[UInt32] $RetryCount = 3,
|
|
||||||
[UInt32] $RetryIntervalSec = 60
|
|
||||||
)
|
|
||||||
|
|
||||||
return [AzureDevOpsApi]::New($TeamFoundationCollectionUri, $ProjectName, $AccessToken, $RetryCount, $RetryIntervalSec)
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
Import-Module (Join-Path $PSScriptRoot "azure-devops-api.ps1")
|
|
||||||
|
|
||||||
class BuildInfo
|
|
||||||
{
|
|
||||||
[AzureDevOpsApi] $AzureDevOpsApi
|
|
||||||
[String] $Name
|
|
||||||
[UInt32] $Id
|
|
||||||
[String] $Status
|
|
||||||
[String] $Result
|
|
||||||
[String] $Link
|
|
||||||
|
|
||||||
BuildInfo([AzureDevOpsApi] $AzureDevOpsApi, [object] $Build)
|
|
||||||
{
|
|
||||||
$this.AzureDevOpsApi = $AzureDevOpsApi
|
|
||||||
$this.Id = $Build.id
|
|
||||||
$this.Name = $Build.buildNumber
|
|
||||||
$this.Link = $Build._links.web.href
|
|
||||||
$this.Status = $Build.status
|
|
||||||
$this.Result = $Build.result
|
|
||||||
}
|
|
||||||
|
|
||||||
[boolean] IsFinished() {
|
|
||||||
return ($this.Status -eq "completed") -or ($this.Status -eq "cancelling")
|
|
||||||
}
|
|
||||||
|
|
||||||
[boolean] IsSuccess() {
|
|
||||||
return $this.Result -eq "succeeded"
|
|
||||||
}
|
|
||||||
|
|
||||||
[void] UpdateBuildInfo() {
|
|
||||||
$buildInfo = $this.AzureDevOpsApi.GetBuildInfo($this.Id)
|
|
||||||
$this.Status = $buildInfo.status
|
|
||||||
$this.Result = $buildInfo.result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-BuildInfo {
|
|
||||||
param (
|
|
||||||
[AzureDevOpsApi] $AzureDevOpsApi,
|
|
||||||
[object] $Build
|
|
||||||
)
|
|
||||||
|
|
||||||
return [BuildInfo]::New($AzureDevOpsApi, $Build)
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
param (
|
|
||||||
[Parameter(Mandatory)] [string] $TeamFoundationCollectionUri,
|
|
||||||
[Parameter(Mandatory)] [string] $AzureDevOpsProjectName,
|
|
||||||
[Parameter(Mandatory)] [string] $AzureDevOpsAccessToken,
|
|
||||||
[Parameter(Mandatory)] [string] $SourceBranch,
|
|
||||||
[Parameter(Mandatory)] [UInt32] $DefinitionId,
|
|
||||||
[Parameter(Mandatory)] [string] $SourceVersion,
|
|
||||||
[Parameter(Mandatory)] [string] $ManifestLink,
|
|
||||||
[Parameter(Mandatory)] [bool] $WaitForBuilds,
|
|
||||||
[string] $ToolVersions,
|
|
||||||
[UInt32] $RetryIntervalSec = 60,
|
|
||||||
[UInt32] $RetryCount = 3
|
|
||||||
)
|
|
||||||
|
|
||||||
Import-Module (Join-Path $PSScriptRoot "azure-devops-api.ps1")
|
|
||||||
Import-Module (Join-Path $PSScriptRoot "build-info.ps1")
|
|
||||||
|
|
||||||
function Get-ToolVersions {
|
|
||||||
param (
|
|
||||||
[Parameter(Mandatory)] [string] $ManifestLink,
|
|
||||||
[Parameter(Mandatory)] [UInt32] $RetryIntervalSec,
|
|
||||||
[Parameter(Mandatory)] [UInt32] $Retries,
|
|
||||||
[string] $ToolVersions
|
|
||||||
)
|
|
||||||
|
|
||||||
[string[]] $versionsList = @()
|
|
||||||
if ($ToolVersions) {
|
|
||||||
$versionsList = $ToolVersions.Split(',')
|
|
||||||
} else {
|
|
||||||
Write-Host "Get the list of releases from $ManifestLink"
|
|
||||||
$releases = Invoke-RestMethod $ManifestLink -MaximumRetryCount $Retries -RetryIntervalSec $RetryIntervalSec
|
|
||||||
$versionsList = $releases.version
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Versions to build: $versionsList"
|
|
||||||
return $versionsList
|
|
||||||
}
|
|
||||||
|
|
||||||
function Queue-Builds {
|
|
||||||
param (
|
|
||||||
[Parameter(Mandatory)] [AzureDevOpsApi] $AzureDevOpsApi,
|
|
||||||
[Parameter(Mandatory)] [string[]] $ToolVersions,
|
|
||||||
[Parameter(Mandatory)] [string] $SourceBranch,
|
|
||||||
[Parameter(Mandatory)] [string] $SourceVersion,
|
|
||||||
[Parameter(Mandatory)] [UInt32] $DefinitionId
|
|
||||||
)
|
|
||||||
|
|
||||||
[BuildInfo[]]$queuedBuilds = @()
|
|
||||||
|
|
||||||
$ToolVersions | ForEach-Object {
|
|
||||||
$version = $_.Trim()
|
|
||||||
Write-Host "Queue build for $version..."
|
|
||||||
$queuedBuild = $AzureDevOpsApi.QueueBuild($version, $SourceBranch, $SourceVersion, $DefinitionId)
|
|
||||||
$buildInfo = Get-BuildInfo -AzureDevOpsApi $AzureDevOpsApi -Build $queuedBuild
|
|
||||||
Write-Host "Queued build: $($buildInfo.Link)"
|
|
||||||
$queuedBuilds += $buildInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
return $queuedBuilds
|
|
||||||
}
|
|
||||||
|
|
||||||
function Wait-Builds {
|
|
||||||
param (
|
|
||||||
[Parameter(Mandatory)] [BuildInfo[]] $Builds,
|
|
||||||
[Parameter(Mandatory)] [UInt32] $RetryIntervalSec
|
|
||||||
)
|
|
||||||
|
|
||||||
do {
|
|
||||||
# If build is still running - refresh its status
|
|
||||||
foreach($build in $builds) {
|
|
||||||
if (!$build.IsFinished()) {
|
|
||||||
$build.UpdateBuildInfo()
|
|
||||||
|
|
||||||
if ($build.IsFinished()) {
|
|
||||||
Write-Host "The $($build.Name) build was completed: $($build.Link)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$runningBuildsCount = ($builds | Where-Object { !$_.IsFinished() }).Length
|
|
||||||
|
|
||||||
Start-Sleep -Seconds $RetryIntervalSec
|
|
||||||
} while($runningBuildsCount -gt 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Make-BuildsOutput {
|
|
||||||
param (
|
|
||||||
[Parameter(Mandatory)] [BuildInfo[]] $Builds
|
|
||||||
)
|
|
||||||
|
|
||||||
Write-Host "`nBuilds info:"
|
|
||||||
$builds | Format-Table -AutoSize -Property Name,Id,Status,Result,Link | Out-String -Width 10000
|
|
||||||
|
|
||||||
# Return exit code based on status of builds
|
|
||||||
$failedBuilds = ($builds | Where-Object { !$_.IsSuccess() })
|
|
||||||
if ($failedBuilds.Length -ne 0) {
|
|
||||||
Write-Host "##vso[task.logissue type=error;]Builds failed"
|
|
||||||
$failedBuilds | ForEach-Object -Process { Write-Host "##vso[task.logissue type=error;]Name: $($_.Name); Link: $($_.Link)" }
|
|
||||||
Write-Host "##vso[task.complete result=Failed]"
|
|
||||||
} else {
|
|
||||||
Write-host "##[section]All builds have been passed successfully"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$azureDevOpsApi = Get-AzureDevOpsApi -TeamFoundationCollectionUri $TeamFoundationCollectionUri `
|
|
||||||
-ProjectName $AzureDevOpsProjectName `
|
|
||||||
-AccessToken $AzureDevOpsAccessToken `
|
|
||||||
-RetryCount $RetryCount `
|
|
||||||
-RetryIntervalSec $RetryIntervalSec
|
|
||||||
|
|
||||||
$toolVersionsList = Get-ToolVersions -ManifestLink $ManifestLink `
|
|
||||||
-RetryIntervalSec $RetryIntervalSec `
|
|
||||||
-Retries $RetryCount `
|
|
||||||
-ToolVersions $ToolVersions
|
|
||||||
|
|
||||||
$queuedBuilds = Queue-Builds -AzureDevOpsApi $azureDevOpsApi `
|
|
||||||
-ToolVersions $toolVersionsList `
|
|
||||||
-SourceBranch $SourceBranch `
|
|
||||||
-SourceVersion $SourceVersion `
|
|
||||||
-DefinitionId $DefinitionId
|
|
||||||
|
|
||||||
if ($WaitForBuilds) {
|
|
||||||
Write-Host "`nWaiting results of builds ..."
|
|
||||||
Wait-Builds -Builds $queuedBuilds -RetryIntervalSec $RetryIntervalSec
|
|
||||||
|
|
||||||
Make-BuildsOutput -Builds $queuedBuilds
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
name: $(date:yyyyMMdd)$(rev:.r)
|
|
||||||
trigger: none
|
|
||||||
pr: none
|
|
||||||
schedules:
|
|
||||||
- cron: "0 3 * * *"
|
|
||||||
displayName: First daily build
|
|
||||||
branches:
|
|
||||||
include:
|
|
||||||
- main
|
|
||||||
always: true
|
|
||||||
- cron: "0 15 * * *"
|
|
||||||
displayName: Second daily build
|
|
||||||
branches:
|
|
||||||
include:
|
|
||||||
- main
|
|
||||||
always: true
|
|
||||||
|
|
||||||
variables:
|
|
||||||
PoolName: 'Azure Pipelines'
|
|
||||||
VmImage: 'ubuntu-18.04'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- stage: Find_New_Versions
|
|
||||||
dependsOn: []
|
|
||||||
jobs:
|
|
||||||
- job: Find_New_Versions
|
|
||||||
pool:
|
|
||||||
name: $(PoolName)
|
|
||||||
vmImage: $(VmImage)
|
|
||||||
steps:
|
|
||||||
- template: /azure-pipelines/templates/get-tool-versions-steps.yml
|
|
||||||
|
|
||||||
- stage: Check_New_Versions
|
|
||||||
dependsOn: Find_New_Versions
|
|
||||||
jobs:
|
|
||||||
- job: Check_New_Versions
|
|
||||||
pool:
|
|
||||||
name: $(PoolName)
|
|
||||||
vmImage: $(VmImage)
|
|
||||||
variables:
|
|
||||||
ToolVersions: $[ stageDependencies.Find_New_Versions.Find_New_Versions.outputs['Get_versions.TOOL_VERSIONS'] ]
|
|
||||||
steps:
|
|
||||||
- template: /azure-pipelines/templates/check-versions.yml
|
|
||||||
|
|
||||||
- stage: Trigger_Builds
|
|
||||||
dependsOn: [Find_New_Versions, Check_New_Versions]
|
|
||||||
condition: and(succeeded(), ne(variables['WORKFLOW_FILE_NAME'], ''))
|
|
||||||
jobs:
|
|
||||||
- deployment: Run_Builds
|
|
||||||
pool:
|
|
||||||
name: $(PoolName)
|
|
||||||
vmImage: $(VmImage)
|
|
||||||
variables:
|
|
||||||
ToolVersions: $[ stageDependencies.Find_New_Versions.Find_New_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
|
|
@ -1,49 +0,0 @@
|
|||||||
steps:
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: Check Versions
|
|
||||||
condition: and(succeeded(), eq(variables.ToolVersions, ''))
|
|
||||||
inputs:
|
|
||||||
TargetType: inline
|
|
||||||
script: |
|
|
||||||
Write-Host "No new versions were found"
|
|
||||||
Import-Module "./azure-devops/azure-devops-api.ps1"
|
|
||||||
|
|
||||||
$azureDevOpsApi = Get-AzureDevOpsApi -TeamFoundationCollectionUri $(System.TeamFoundationCollectionUri) `
|
|
||||||
-ProjectName $(System.TeamProject) `
|
|
||||||
-AccessToken $(System.AccessToken)
|
|
||||||
|
|
||||||
$AzureDevOpsApi.UpdateBuildStatus($(Build.BuildId), 'Cancelling') | Out-Null
|
|
||||||
Start-Sleep -Seconds 60
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: 'Set PIPELINE_URL variable'
|
|
||||||
inputs:
|
|
||||||
TargetType: inline
|
|
||||||
script: |
|
|
||||||
$ToolName = "$(TOOL_NAME)"
|
|
||||||
if ($ToolName -eq "Python") {
|
|
||||||
$PipelineUrl = " "
|
|
||||||
} else {
|
|
||||||
$PipelineUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)"
|
|
||||||
}
|
|
||||||
Write-Host "##vso[task.setvariable variable=PIPELINE_URL]$PipelineUrl"
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: 'Change build name'
|
|
||||||
inputs:
|
|
||||||
TargetType: inline
|
|
||||||
script: |
|
|
||||||
$newBuildName = "[FOUND] $(Build.BuildNumber)"
|
|
||||||
Write-Host "##vso[build.updatebuildnumber]$newBuildName"
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: 'Send Slack notification'
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './get-new-tool-versions/send-slack-notification.ps1'
|
|
||||||
arguments: |
|
|
||||||
-Url "$(SLACK_CHANNEL_URL)" `
|
|
||||||
-ToolName "$(TOOL_NAME)" `
|
|
||||||
-ToolVersion "$(ToolVersions)" `
|
|
||||||
-PipelineUrl "$(PIPELINE_URL)" `
|
|
||||||
-ImageUrl "$(IMAGE_URL)"
|
|
@ -1,9 +0,0 @@
|
|||||||
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: |
|
|
||||||
-ToolName "$(TOOL_NAME)"
|
|
@ -1,15 +0,0 @@
|
|||||||
steps:
|
|
||||||
- checkout: self
|
|
||||||
|
|
||||||
- task: PowerShell@2
|
|
||||||
displayName: 'Run builds'
|
|
||||||
inputs:
|
|
||||||
targetType: filePath
|
|
||||||
filePath: './github/run-ci-builds.ps1'
|
|
||||||
arguments: |
|
|
||||||
-RepositoryFullName $(REPOSITORY_FULL_NAME) `
|
|
||||||
-AccessToken $(GITHUB_TOKEN) `
|
|
||||||
-WorkflowFileName $(WORKFLOW_FILE_NAME) `
|
|
||||||
-WorkflowDispatchRef $(DISPATCH_REF) `
|
|
||||||
-ToolVersions "$(ToolVersions)" `
|
|
||||||
-PublishReleases $(PUPLISH_RELEASES)
|
|
Loading…
Reference in New Issue