-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added additional logs to identify script errors #12159
Conversation
@@ -11,18 +11,19 @@ $__vsts_input_failOnStandardError = Get-VstsInput -Name FailOnStandardError | |||
$targetAzurePs = Get-VstsInput -Name TargetAzurePs | |||
$customTargetAzurePs = Get-VstsInput -Name CustomTargetAzurePs | |||
|
|||
Write-Host "## Stage 1: Input Validation" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can skip "stage 1". Just "## Validating inputs" would be fine.
|
||
Write-Host "## Stage 2: Initialize Azure" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"## Initializing Azure"
@@ -74,10 +78,27 @@ catch | |||
|
|||
Update-PSModulePathForHostedAgent -targetAzurePs $targetAzurePs -authScheme $authScheme | |||
|
|||
# troubleshoot link | |||
$troubleshoot = "https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-powershell?view=azure-devops#troubleshooting" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a forward link instead.
@@ -74,10 +78,27 @@ catch | |||
|
|||
Update-PSModulePathForHostedAgent -targetAzurePs $targetAzurePs -authScheme $authScheme | |||
|
|||
# troubleshoot link | |||
$troubleshoot = "https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-powershell?view=azure-devops#troubleshooting" | |||
$status = $true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need to define this variable here. You can set it directly after the write-host statement.
try { | ||
# Initialize Azure. | ||
Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_ | ||
Initialize-Azure -azurePsVersion $targetAzurePs -strict | ||
Write-Host "## Stage 2: Initialize Azure Complete" | ||
} | ||
catch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need catch here. In 'finally' block, check for whether or not status is exists. That will work.
} | ||
finally { | ||
if (!$status) { | ||
Write-Host "## Initialize Azure failed: For troubleshooting, refer: $troubleshoot" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using Write-Host here try using Write-VstsError
finally { | ||
if (!$success) { | ||
Write-VstsTaskError "Initialize Azure failed: For troubleshooting, refer: $troubleshoot" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should also be a message saying "Azure initialization complete"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have added this log "Write-Host "## Initializing Azure Complete"" after Initialize-Azure is completed
No description provided.