Closed donwlewis closed 4 years ago
Thank you for reporting this. this is not a bug. And actually this is also not happening. The output on the console is indeed in the wrong order and makes you believe it's a problem in the behavior. But actually it's only the output to the console which is wrong.
host output tends to appear before standard output regular output gets a minimum 300ms delay so the formatter has time to see if it needs to group objects into tables etc
If you do
$session = New-Session -Cred $cred
Write-Host "the user is $($session.Username)"
you will see that the behavior is indeed fine.
Note:
with the next jira version, New-JiraVersion
will no longer output data by default, but offer a -Passthru
parameter
I think you dismissed this too soon. You may be correct, but it does not work properly. If you try running the following function:
function Test {
param (
$Server,
$Creds
)
Set-JiraConfigServer -Server $Server
New-JiraSession -Credential $Creds
Write-Host "I am here"
Get-JiraProject
}
You will see that you never get a list of projects back. Its like the Get-JiraProject
command runs before the session is fully established.
In my console I see that the output of the commands break the console, but the commands are run just fine demo:
$out = test -server … -cred $cred
$out | gm
$out[0]
$out[1]
$out[2]
by storing the session in a variable, it works properly:
function Test {
param (
$Server,
$Creds
)
Set-JiraConfigServer -Server $Server
$null = New-JiraSession -Credential $Creds
Write-Host "I am here"
Get-JiraProject
}
Thanks @lipkau for clarification.
Description
When using
New-JiraSession
in a custom function, it appears that the function will continue on without waiting for the cmdlet to finish.Steps To Reproduce
Write a function that uses the
New-JiraSession
cmdlet and try to run it. You will notice command that are written after theNew-JiraSession
line will run even the the cmdlet hasn't completed.Expected behavior
I would expect the function to wait fo the cmdlet to finish before moving on.
Screenshots
Your Environment