Managing a Spring Boot self-executable application
I'm working on a project where we are taking a "microservice" approach with a bunch of Spring Boot self-executable JAR files (instead of generating the WAR file and deploying it to a servlet container).
Focusing on one of the microservices (just to make it simple), I managed to properly configure it as a project in Jenkins using Git as the Source Code Management and then Gradle to build it --> gradle build
After Jenkins executes the "gradle build" command, I need to "execute" the just-generated JAR file in a separate process, so Jenkins can finish up the build and wait for the next one (whatever the trigger mechanism is). However, I've been playing around different configurations to execute the JAR file and I cannot find the one which fits perfectly my requirements (remember: after gradle finishes the build, execute the JAR file and end the Jenkins build process).
To put it step-by-step, this is what I'm trying to achieve:
1. Pull latest changes from Git repository.
2. Execute shell to kill (if existing from a previous build) the current JAR execution.
3. Run the gradle build task.
4. Execute shell to start up the self-executable/bootable JAR file.
5. Email notification.
This is what I have accomplished so far, but not sure whether it's the best approach or not, so asking the experts in this list:
However, although Jenkins runs this shell script properly, it uses the same thread where Jenkins runs the build, so eventually the build keeps running forever and "linked" to the execution of the JAR file.
I then tried to execute it in the background by appending '&' at the end of the script:
But then Jenkins seems to not like it, because although it executes the shell script, the JAR application is not started up. I presume this is due to the fact that Jenkins finishes up the build process and the system automatically kills the '&' process, not sure, but it definitively doesn't work.
Therefore, I would like to understand how to achieve in Jenkins the scenario where I have to build a JAR file, then execute it (java -jar <generated_jar_file>) and end up the build, leaving the JAR application running as an independent process.
Moreover, this example shows only one JAR file, but as you can imagine, I would be generating a bunch of them, and I would like to execute them as JAR files once they are build, all in independent processes. Should I set up one Jenkins job per microservice? Or should I handle all them together in a single job? Please advice.
Thanks in advance for your help.
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.