Octopus treats OpenSSL (Loading 'screen' into random state) as error

How can I make Octopus treat the OpenSSL output “Loading ‘screen’ into random state” as normal output and not an error?

Right now when I run a deployment I get a warning in my completion that Octopus received a 0 exit code, but had warnings. The thing is, I’m not sure why “Loading ‘screen’ into random state” is considered an error.

Especially since when I run the same command in the console, it is NOT an error.

Also, I tried using out-null but it was to no avail.

New-PfxCertificate $params $es.certificates.codeSigning.password | out-null
function New-PfxCertificate {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$true,position=0, ValueFromPipeline=$true, ParameterSetName='a')] [hashtable] $certData,
        
        [Parameter(Mandatory=$true,position=0, ParameterSetName='b')][alias('out')][string] $outPath,
        [Parameter(Mandatory=$true,position=1, ParameterSetName='b')][string] $key,
        [Parameter(Mandatory=$true,position=2, ParameterSetName='b')][string] $crt,
        [Parameter(Mandatory=$true,position=3, ParameterSetName='b')][string] $name,

        [Parameter(Mandatory=$true,position=1, ParameterSetName='a')]
        [Parameter(Mandatory=$true,position=4, ParameterSetName='b')]
        [alias('pwd')][string] $password
    )

    if($PsCmdlet.ParameterSetName -eq 'b') {
        # Recursive call using the hashtable
        New-PfxCertificate  @{
            'path' = $outPath
            'key' = $key
            'crt' = $crt
            'name' = $name
        }
    }
    
    $env:RANDFILE = $RANDFILE = "$outpath\.rnd"

    $pfx = "$($certData.name).pfx"

    try{
        Find-ToolPath 'openssl.exe'
        Push-Location $certData.path
        $key = if(Test-Path $certData.key -erroraction silentlycontinue){ $certData.key } else { GenerateCertFromString $certData.name $certData.key 'key' }
        $crt = if(Test-Path $certData.crt -erroraction silentlycontinue){ $certData.crt } else { GenerateCertFromString $certData.name $certData.crt 'crt' }
        Set-OpenSslConfigPath
        Exec { openssl.exe pkcs12 -export -inkey $key -in $crt -out $pfx -name $certData.name  -passout pass:$password | out-null} 
    } finally {
        Pop-Location
        Clear-TemporaryCertificates
        Remove-Item "$outpath\.rnd" -Force -ErrorAction SilentlyContinue
    }
    
    $certData.key = $key
    $certData.crt = $crt
    $certData.Add('pfx', $pfx)
    Write-output $certData
}
function Invoke-ExternalCommand
{
    [CmdletBinding()]
    param(
        [Parameter(Position=0,Mandatory=$true)][scriptblock] $command,
        [Parameter(Position=1,Mandatory=$false)][string] $errorMessage,
        [Parameter(Mandatory=$false)] [int] $retry = 0,
        [Parameter(Mandatory=$false)] [int] $msDelay = 250
    )
 
    # Setting ErrorAction to Stop is important. This ensures any errors that occur in the command are 
    # treated as terminating errors, and will be caught by the catch block.
    $ErrorAction = "Stop"
    
    $retrycount = 0
    $completed = $false

    while (-not $completed) {
        try {
            & $command

            if ($lastexitcode -ne 0) {
                $e = if($errorMessage){$errorMessage} else {($error[0].ErrorDetails | out-string)} 
                throw $e
            } else {
                $completed = $true
            }
        } catch {
            if ($retrycount -ge $retry) {
                Write-Verbose ("Command [{0}] failed after {1} retries." -f $command, $retrycount)
                throw $_
            } else {
                Write-Verbose ("Command [{0}] failed. Retrying in {1}ms" -f $command, $msDelay)
                Write-Verbose $_
                Start-Sleep -m $msDelay
                $retrycount++
            }
        $lastexitcode = 0
        }
    }
}
Set-Alias Exec Invoke-ExternalCommand

Hi Chase,

You can do this (and still capture the output) by writing this:

Write-Host "##octopus[stderr-progress]"
# script that emits information to stderr
Write-Host "##octopus[stderr-default]"

Those special messages tell Octopus to treat the output between them differently - in this case treating stderr output as information.

Hope this helps,

Paul

Wonderful, thanks Paul… I had no idea that was there. It’ll be a good work-around until OpenSSL fixes their issue.

After

@PaulStovell, are there any other service messages available from Octopus?

Write-Host "##octopus[xxxxxxx]"

Hi Chase,

Hope this helps:

stdout-ignore
stdout-error
stdout-default
stdout-warning
stdout-verbose
stderr-ignore
stderr-progress
stderr-error
stderr-default

Cheers,
Shane