Calling console application from Azure DevOps Release Pipeline

9

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.

powershell
azure-devops
console
azure-pipelines
azure-pipelines-release-pipeline
asked on Stack Overflow Dec 27, 2019 by Mike • edited Dec 27, 2019 by Mike

3 Answers

2

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

answered on Stack Overflow Jul 28, 2020 by hmz • edited Jul 28, 2020 by hmz
0

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.

It seems that that release pipeline has finished and returned with success status at that time.

So I think your crash could result from the default behavior of VSTS, it will close all the process launched during the build/release after it is finished. Just like what jessehouwing describes here.

answered on Stack Overflow Dec 30, 2019 by LoLance
0

Running the agent interactively solved the problem. I created a second agent on the server and when configuring I left off the "--runasservice" and just ran the agent by hand ".\run"

answered on Stack Overflow Dec 30, 2019 by Mike

User contributions licensed under CC BY-SA 3.0