-
Notifications
You must be signed in to change notification settings - Fork 425
Enhanced the functionality of SqlDacPacDeploymentonOnMachineGroupV0 #1269
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
base: master
Are you sure you want to change the base?
Enhanced the functionality of SqlDacPacDeploymentonOnMachineGroupV0 #1269
Conversation
|
@microsoft-github-policy-service agree company="Microsoft" |
…entOnMachineGroupV0
| $trimmedOutput -split "`r?`n" | ForEach-Object { Write-Output $_ } | ||
| } | ||
| else { | ||
| Invoke-Expression "Invoke-SqlCmd @spaltArguments $additionalArguments" |
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.
Do you know if we can remove the Invoke-Expression and use directly Invoke-SqlCmd ?
Invoke-SqlCmd @invokeParams $additionalArguments
where params can probably be created by
$invokeParams = @{}
$spaltArguments.Keys | ForEach-Object {
}
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.
We can’t remove Invoke-Expression because $additionalArguments is a text string, not real parameters.
Invoke-SqlCmd can’t understand that text directly. It only works with proper named parameters.
Invoke-Expression is needed to run the full command as written in the string.
| $commandToRun = $commandToLog + " " + $additionalArguments | ||
| $command = "Invoke-SqlCmd @spaltArguments $additionalArguments" | ||
|
|
||
| Write-Host "##[command] $commandToRun" |
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.
can you make a test if additional arguments contains secret if the agent will suppress those values?
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.
Yeah, Razvan the agent is suppressing the value when the additional arguments contain secret, and the task is consuming its value.
|
|
||
| Write-Host "##[command] $commandToRun" | ||
|
|
||
| if ($additionalArguments.ToLower().Contains("-verbose")) { |
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 we also have abbreviations like -v , or are there any possible arguments like -verbose:false
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.
No, I don't believe that's the case. I tested using both -v and -verbose:false, and we didn't receive verbose output in the logs.
|
|
||
| Write-Verbose "Invoke-SqlCmd arguments : $commandToLog $additionalArguments" | ||
| Invoke-Expression "Invoke-SqlCmd @spaltArguments $additionalArguments" | ||
| $commandToRun = $commandToLog + " " + $additionalArguments |
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.
Should we consider adding this entire change under FF ?
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.
Sure, added the entire change under the FF
| if ($additionalArguments.ToLower().Contains("-verbose")) { | ||
| $errors = @() | ||
|
|
||
| $rawOutput = (Invoke-Expression $command -ErrorVariable errors 4>&1 | Out-String) |
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.
wouldn't this introduce delays in providing output ? before with just invoke we would have live steaming but with this we will buffer the entire output until command finishes and after we will re-emit each line.
we will loose object types as everything is converted to plain text
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.
Fixed the buffering the entire output in the next commit.
and the object type "loss" is intentional and appropriate since we're displaying results to users in logs, not passing data to other PowerShell code.
Description: Added verbose log functionality while passing verbose as additional arguments
Documentation changes required: (Y/N) N
Added unit tests: (Y/N) N
Attached related issue: (Y/N) microsoft/azure-pipelines-tasks#21025