Skip to content
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

Merged
merged 6 commits into from
Feb 3, 2020

Conversation

aksm-ms
Copy link
Contributor

@aksm-ms aksm-ms commented Jan 16, 2020

No description provided.

@aksm-ms aksm-ms requested a review from arjgupta January 16, 2020 08:39
@aksm-ms aksm-ms requested a review from kmkumaran as a code owner January 16, 2020 08:39
@@ -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"
Copy link
Member

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"
Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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 {
Copy link
Member

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"
Copy link
Member

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"
}
Copy link
Member

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"

Copy link
Contributor Author

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

@aksm-ms aksm-ms merged commit 1b37e11 into master Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants