Skip to content

Instantly share code, notes, and snippets.

@onesmartguy
Created March 13, 2020 23:47
Show Gist options
  • Save onesmartguy/b72edcc38a858acfc9565f809dd48b18 to your computer and use it in GitHub Desktop.
Save onesmartguy/b72edcc38a858acfc9565f809dd48b18 to your computer and use it in GitHub Desktop.
parameters:
packages: ''
options: '-y --no-progress --limitoutput'
steps:
- powershell: |
if ((Get-Command "choco.exe" -ErrorAction SilentlyContinue) -eq $null) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString("https://chocolatey.org/install.ps1"))
echo "##vso[task.setvariable variable=PATH]$env:PATH"
echo $env:PATH
} else {
echo "choco already installed"
}
displayName: 'Install choco'
condition: and(ne(variables.hasChanges, 'false'), ne(variables.hasChanges, False))
- ${{ if ne(parameters.packages, '') }}:
- powershell: |
choco install ${{ parameters.options }} ${{ parameters.packages }}
if ($lastexitcode -ne 0) {
get-content -path "C:\ProgramData\chocolatey\logs\chocolatey.log"
throw
}
displayName: "Install choco packages"
condition: and(ne(variables.hasChanges, 'false'), ne(variables.hasChanges, False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment