Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling console application from Azure DevOps Release Pipeline

Trying to have a Azure DevOps Release pipeline that has a deployment agent installed on-prem run a console application as a specific user that has access to an on-prem database.

This is the workflow

Azure Release Pipeline calls-> Agent on-prem runs-> PS Script runs-> console exe

I'm using the PowerShell task in the pipeline with this inline script:

$CMD = '$CMD = 'C:\ScheduledScripts\Adm\SpecToHobImport\SpecToHobImport.exe''
$user = $Env:userid
$password = $Env:pass
$dates = '$(startDate) $(endDate)'

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $user, $securePassword

Start-Process -FilePath $CMD -Credential $credential -ArgumentList "$(startDate) $(endDate)" 

I know the userid and password and command line arguments are being delivered properly, but no matter how simple the console application is made it crashes when the agent runs the powershell script. I've tried running the DevOps agent service under various service accounts (System, administrator, etc) and I can run the script manually on the server the agent is installed on and the script and console application runs fine manually.

When I run the Release pipeline it reports back in DevOps that it runs successfully and I can only detect that the console app has run and immediately crashed is from the windows event log on the agent server.

I get the following two entries in the EventLog:

Faulting application name: conhost.exe, version: 6.3.9600.17415, time stamp: 0x5450410b
Faulting module name: USER32.dll, version: 6.3.9600.19478, time stamp: 0x5d6aa558
Exception code: 0xc0000142
Fault offset: 0x00000000000ecf30
Faulting process id: 0x770
Faulting application start time: 0x01d5bcdf64d0ac17
Faulting application path: C:\Windows\system32\conhost.exe
Faulting module path: USER32.dll
Report Id: a292ad24-28d2-11ea-8103-0050569f788f
Faulting package full name: 
Faulting package-relative application ID: 

and this entry:

Faulting application name: SpecToHobImport.exe, version: 1.0.0.0, time stamp: 0x5e06463f
Faulting module name: KERNELBASE.dll, version: 6.3.9600.18895, time stamp: 0x5a4b127e
Exception code: 0xc0000142
Fault offset: 0x0009d4e2
Faulting process id: 0x40c
Faulting application start time: 0x01d5bcdf64d0ac17
Faulting application path: C:\ScheduledScripts\Adm\SpecToHobImport\SpecToHobImport.exe
Faulting module path: KERNELBASE.dll
Report Id: a2a5c015-28d2-11ea-8103-0050569f788f
Faulting package full name: 
Faulting package-relative application ID: 

Even a console application with an empty main results in an app crash.

like image 980
Mike Avatar asked Dec 27 '19 18:12

Mike


1 Answers

All the process launched in the release will be finished when the release is over. If you don't want the process to be closed, try setting variable Process.clean= false.

But when you create a new release next time, you need to stop process before starting it.

Azure devops release pipeline variables process.clean=false

like image 133
hmz Avatar answered Sep 25 '22 15:09

hmz