Skip to content

Commit

Permalink
Add Azure Pipelines definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed May 20, 2019
1 parent 364068f commit 6d02626
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 150 deletions.
146 changes: 0 additions & 146 deletions .appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Chocolatey packages maintained by [BBT Software AG](http://www.bbtsoftware.ch).

[![Build status](https://ci.appveyor.com/api/projects/status/a31t23xs5lycw79h/branch/master?svg=true)](https://ci.appveyor.com/project/BBTSoftwareAG/chocolatey-packages/branch/master)
[![Build Status](https://dev.azure.com/bbtsoftwareag/chocolatey-packages/_apis/build/status/bbtsoftware.chocolatey-packages?branchName=master)](https://dev.azure.com/bbtsoftwareag/chocolatey-packages/_build/latest?definitionId=1&branchName=master)
[![](http://transparent-favicon.info/favicon.ico)](#)
[Update status](https://gist.github.com/bbt-bot/b601bc1e0835054f4df23310100983ee)
[![](http://transparent-favicon.info/favicon.ico)](#)
Expand Down
125 changes: 125 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
trigger:
- master

pr:
- master

jobs:
- job: Windows
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)
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" }
displayName: 'Collecting build artifacts'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
displayName: 'Publishing build artifacts'
11 changes: 9 additions & 2 deletions scripts/Test-RepoPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,19 @@ function SetAppveyorExitCode() {
)
WriteOutput "Exit code was $ExitCode" -type Warning

if (!(Test-Path env:\APPVEYOR)) {
if ($ExitCode -eq 0) {
return
}
if ($ExitCode -ne 0) {

if ((Test-Path env:\APPVEYOR)) {
$host.SetShouldExit($ExitCode)
}

if ((Test-Path env:\TF_BUILD)) {
$host.SetShouldExit($ExitCode)
}

return
}

function RunChocoProcess() {
Expand Down
2 changes: 1 addition & 1 deletion update_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if ($ForcedPackages) { Write-Host "FORCED PACKAGES: $ForcedPackages" }
$global:au_Root = $Root #Path to the AU packages
$global:info = Update-AuPackages -Name $Name -Options $Options

#Uncomment to fail the build on AppVeyor on any package error
#Uncomment to fail the build on build server on any package error
if ($global:info.error_count.total) {
WriteOutput "Update failed with message: $global:info.result.all" -type Error
throw 'Errors during update'
Expand Down

0 comments on commit 6d02626

Please sign in to comment.