M
M
Max2017-12-28 16:31:35
linux
Max, 2017-12-28 16:31:35

How to properly run jar on a remote machine using jenkins?

Hello !
I have a question, what is the best way to run a jar file (spring-boot if anyone is interested) on a remote host.
there is the following flow:
1. jenkins build jar
2. jenkins connects to the host, uploads the necessary files
3. jenkins executes java -jar app.jar
4. jenkins closes the connection, thus closes the launch of the java command
as a result, jenkins says that the build was successful
and in fact, the application does not work
. any ideas how to do step 3-4 in such a way that
1. the application is NOT closed along with the closing of the jenkins session?
2. let jenkins know if the application has risen successfully, or has not taken off (there is an exception at startup or something like that)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2017-12-28
@Maxon4eg92

3. Jenkins executes java -jar app.jar
Run application in background with nohup
4. Jenkins closes connection, thus closes running java command
Closing java command launched via nohup will not happen, but you will need to add a step that can check if that the application has started. and a step that will subsequently stop the application.
For example, check log files for certain words (ERROR, FAIL).
Or add some API to your application that you can pull, and it will answer "application version xxx is running"
And add a stop to your application - through kill or through the same API.

D
Dmitry Eremin, 2017-12-28
@EreminD

what do steps 2, 3 and 4 look like? more?
It's just that jenkins starts the process and must wait for it to finish
. And then just go to step (4)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question