* Add autorest-preview pipeline * Add emitternpminstall * Always install * Use shorter leg name * Add short circuiting to emitter install * Use language matrix function * Don't look for subfolders in the matrix package folders * Revert unnecessary eng/common changes * Rewrite GetPullRequestUrl to Get-BuildSourceDescription * Remove alias from Invoke-LoggedCommand * Use invoke-expression instead of shelling out * Add better job splitting * Replace Folder with Directory --------- Co-authored-by: Patrick Hallisey <pahallis@microsoft.com>
43 lines
945 B
PowerShell
43 lines
945 B
PowerShell
function Invoke-LoggedCommand($Command, $ExecutePath, [switch]$GroupOutput)
|
|
{
|
|
$pipelineBuild = !!$env:TF_BUILD
|
|
$startTime = Get-Date
|
|
|
|
if($pipelineBuild -and $GroupOutput) {
|
|
Write-Host "##[group]$Command"
|
|
} else {
|
|
Write-Host "> $Command"
|
|
}
|
|
|
|
if($ExecutePath) {
|
|
Push-Location $ExecutePath
|
|
}
|
|
|
|
try {
|
|
Invoke-Expression $Command
|
|
|
|
$duration = (Get-Date) - $startTime
|
|
|
|
if($pipelineBuild -and $GroupOutput) {
|
|
Write-Host "##[endgroup]"
|
|
}
|
|
|
|
if($LastExitCode -ne 0)
|
|
{
|
|
if($pipelineBuild) {
|
|
Write-Error "##[error]Command failed to execute ($duration): $Command`n"
|
|
} else {
|
|
Write-Error "Command failed to execute ($duration): $Command`n"
|
|
}
|
|
}
|
|
else {
|
|
Write-Host "Command succeeded ($duration)`n"
|
|
}
|
|
}
|
|
finally {
|
|
if($ExecutePath) {
|
|
Pop-Location
|
|
}
|
|
}
|
|
}
|