0

I am trying to setup a azureDevOps pipeline for android testing on self-hosted agent(windows). For this, I need to start an emulator as a detached process in background.

I am successfully able to start a process in background using following command.

Start-Job -Name EM -ScriptBlock {D:\Android\Sdk\tools\emulator -avd testAVD -no-audio -no-window }

But this process is attached to the parent process, and hence, when Azure pipeline exits the current task, as a part of clean up - it kills this emulator also (beats my purpose of creating the emulator in first place).

So, Can anyone suggest how can I start a detached background process in powerShell? Thanks in advance!

P.S: There is one relevant post, however, it looks to be very java specific. Start a detached background process in PowerShell

I have tried

  1. Start-Job -Name EM -ScriptBlock {& D:\Android\Sdk\tools\emulator -avd testAVD -no-audio -no-window } This looks to be not working.

  2. StartThread-Job -Name EM -ScriptBlock {D:\Android\Sdk\tools\emulator -avd testAVD -no-audio -no-window } For this, Azurepipeline task doesnt even exit. So, this also doesnt work. Moreover, I dont think this would be a solution either, beacause by definiation of StartThread-Job, it starts a new thread in same process. Dont think it talks about detachment at all.

Any suggestions?.

Smodi2007
  • 21
  • 3
  • 1
    this doesnt really make sense. pipeline runs while the script inside runs. even if you would succeed in creating a detached process that runs your stuff - pipeline will exit as soon as you finish creating it, because your main script exits. what problem are you trying to solve? – 4c74356b41 Jun 29 '19 at 14:13
  • Hey das. You are correct - only when the said task is the last task of pipeline, Not otherwise. In my case, said task is one of the first tasks I m doing. Problem I m trying to solve-- I am trying to create an emulator, on which I will run some connectedandroidtest later in next task (cannot club these tasks as this one is a gradle task). I am doing this all as a part of testing the new app I am developing. – Smodi2007 Jun 30 '19 at 12:10
  • @Ansgar Wiechers – Smodi2007 Jul 01 '19 at 18:35

0 Answers0