forked from bbtsoftware/chocolatey-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
130 lines (123 loc) · 5.4 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
trigger:
- master
pr:
- master
jobs:
- job: Windows
# Allow to run just before next scheduled run starts
timeoutInMinutes: 350
strategy:
maxParallel: 1
pool:
vmImage: 'vs2017-win2016'
variables:
# Set au version to use or omit to use the latest. Specify branch name to use development version from Github
au_version:
au_push: true
# Use 1 to test all, or N to split testing into N groups
au_test_groups: 1
# Github token to commit pushed packages to repository
github_user_repo: bbtsoftware/chocolatey-packages
# ID of the gist used to save run results - create a gist under the github_user (secret or not) and grab the id - https://gist.github.com/name/id
# Optional, leave empty to create anonymous gist
gist_id: b601bc1e0835054f4df23310100983ee
#ID of the gist used to save test run results
gist_id_test: c72aa859cc786592b658a439f10fb5fc
# Chocolatey API key - to push updated packages
#Chocolatey version we want to use when checking for updates (usually latest).
choco_version: '0.10.13'
choco_version_pr: '0.10.8' # Should be kept to the version available one year ago
nupkg_cache_path: C:\packages
steps:
- powershell: |
git config --global user.email "[email protected]"
git config --global user.name "BBT Software AG"
git config --global core.safecrlf false
displayName: 'Initialize Git environment'
- powershell: |
$chocoVersion = if (($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER -eq $null) -or ($ENV:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER -eq '')) { $Env:choco_version } else { $Env:choco_version_pr }
if (!(Test-Path "$env:nupkg_cache_path")) { mkdir -Force "$env:nupkg_cache_path" }
@{
'chocolatey' = $chocoVersion
'wormies-au-helpers' = '0.3.2'
}.GetEnumerator() | % {
if (!(Test-Path "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg")) { rm "${env:nupkg_cache_path}\$($_.Key).*.nupkg" ; iwr "https://chocolatey.org/api/v2/package/$($_.Key)/$($_.Value)" -OutFile "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg" }
if ($_.Key -eq 'chocolatey') { cup $_.Key --version $_.Value --source ${env:nupkg_cache_path} --allow-downgrade }
else { cinst $_.Key --version $_.Value --source ${env:nupkg_cache_path} --ignore-dependencies }
}
rm "$env:ChocolateyInstall\logs\*.log"
displayName: 'Initialize Chocolatey'
- powershell: |
Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version
$PSVersionTable
git --version
choco --version
displayName: 'Show environment information'
- powershell: |
git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au
. "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
displayName: 'Clone AU'
- powershell: |
"Build info"
' {0,-20} {1}' -f 'Build reason:', $Env:BUILD_REASON
displayName: 'Show build information'
- powershell: |
$ErrorActionPreference = 'Continue'
. ./scripts/EventLogs.ps1
Clear-EventLogs
if ($Env:BUILD_DEFINITIONNAME -like '*test*') { ./test_all.ps1 "random $Env:au_test_groups"; return }
if (($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER -ne $null) -and ($Env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER -ne '')) {
Set-Service wuauserv -StartupType Manual
./scripts/Test-RepoPackage.ps1 -CleanFiles -TakeScreenshots
return
} else {
# Clean the choco logs as it's quite large
rm "$env:ChocolateyInstall\logs\*.log"
}
if ( ($Env:BUILD_REASON -eq 'IndividualCI') -or ($Env:BUILD_REASON -eq 'BatchedCI') ) {
switch -regex ($Env:BUILD_SOURCEVERSIONMESSAGE)
{
'\[AU (.+?)\]' { $forced = $Matches[1] }
'\[PUSH (.+?)\]' {
$packages = $Matches[1] -split ' '
Write-Host "PUSHING PACKAGES: $packages"
foreach ($package in $packages) {
Write-Host ("{0}`n{1}`n" -f ('-'*60), "PACKAGE: $package")
$package_dir = ls -recurse | ? { $_.Name -eq "$package.nuspec"} | select -First 1 | % Directory
if (!$package_dir) { Write-Warning "Can't find package '$package'"; continue }
pushd $package_dir
if (Test-Path update.ps1 -ea 0) { ./update.ps1 }
choco pack; Push-Package -All;
popd
}
return
}
}
}
./update_all.ps1 -ForcedPackages $forced
Get-EventLogs * | ? Source -eq 'Schannel' | fl * | out-file eventlogs.txt
env:
api_key: $(api_key)
github_api_key: $(github_api_key)
continueOnError: true
displayName: 'Run build'
- powershell: |
if (Test-Path $Env:TEMP\chocolatey\au) { 7z a -mx9 au_temp.7z $Env:TEMP\chocolatey\au\* }
$paths = @(
Resolve-Path "$env:TEMP\artifacts\*" -ea 0
Resolve-Path "$env:ChocolateyInstall\logs\*.log" -ea 0
'au_temp.7z'
'update_info.xml'
'Update-AUPackages.md'
'Update-History.md'
'eventlogs.txt'
)
$paths | ? { Test-Path $_ } | % { Copy-Item "$_" -Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY" }
condition: succeededOrFailed()
displayName: 'Collecting build artifacts'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
condition: succeededOrFailed()
displayName: 'Publishing build artifacts'