Restarting Jenkins Agent after VM Snapshot Recovery

Viewed 33

I am working on a desktop version of Continious Integration Testing. I am using HyperV for Testinf Enviroment VMs. Those VMs have Snapshots, that are restored after every testrun. However i am stuck on the point where i need to restart the Jenkins agent on the recovered VM.

My best attempt was to inject a powershell command to restart the agent, which actually starts the agent. But it will immediatly close after the injection since there is no valid session that will keep it up.

The command I used to test this:

Invoke-Command -VMName VMName -Scriptblock {Start-Process -FilePath "C:\Jenkins\JenkinsAgentStart.bat"} -credential $credential

I also tried starting this as a new process. The result remains the same. I can see the Java RAM going up for a second and dropping immediatly whilst seeing the connection result of my Jenkins agent in the injected powershell window.

Is there a way to start the Jenkins Agent using the HyperV Host AND keeping it up after resetting the VMs Snapshot?

0 Answers
Related