I have a mock server which I need to start in Jenkins before running my Automation tests and then stop the mock server after my tests have run.
This mock server is a maven project and is using exec-maven-plugin
. I am able to start this server by running the command mvn exec:java
. However I am unable to stop this maven project through Jenkins. I have read about it and most answers tell to find the Process ID of this Maven project and then kill it. Is there a cleaner and easier way to stop this project ?
The key to this issue is indeed that you don't know the processId. Consider using
exec:exec
instead with async. You'll see that asyncDestroyOnShutdown is set to true by default, meaning it'll shut down once Maven is shutting down.