TO summarize my use case, I used to have a local project batch file that called IZPACK’s compile.bat in an Azure Devops pipeline. There was an error with the build that didn’t fail the pipeline so I added the check to fail on stderr. Now there is an error being reported that was never seen before checking for stderr,
##[error]Jul 01, 2024 11:37:50 AM com.izforge.izpack.compiler.CompilerConfig <init>
In order to fix the issue I thought to change from a batch file to a powershell script for error handling.
build_izpack.ps1
& "$env:IZPACK_HOMEbincompile.bat" install.xml -b . -o "$env:userprofilePinPointRTLSSetup.jar" -k standard
now I have tried using
try{
& "$env:IZPACK_HOMEbincompile.bat" install.xml -b . -o "$env:userprofilePinPointRTLSSetup.jar" -k standard
} catch {
Write-Host "This is an error"
}
as well as redirects
& "$env:IZPACK_HOMEbincompile.bat" install.xml -b . -o "$env:userprofilePinPointRTLSSetup.jar" -k standard 2>&1
I even used Start-Process with exit code passthrough
$A = Start-Process "$env:IZPACK_HOMEbincompile.bat" -ArgumentList @("install.xml", "-b", ".", "-o", "$env:userprofilePinPointRTLSSetup.jar", "-k", "standard") -Wait -passthru;$a.ExitCode
$A.ExitCode
I forget which options returned just the string of an error like above and which threw and native command error like this below.
##[error]compile.bat : Jul 01, 2024 6:32:15 AM com.izforge.izpack.compiler.CompilerConfig <init>
At C:devopseng-builder04-agent_work5sPinpointInstallerinstallerbuild_server_compiler_powershell.ps1:49 char:1
+ & "$env:IZPACK_HOMEbincompile.bat" install.xml -b . -o "$env:userpr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Jul 01, 2024 6:...erConfig <init>:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
but each time, the script fails with the error line and without being handled. I’m looking for what I might be doing wrong with any of the options I have already used or if there is something I am missing to handle this.