Jar stops after Jenkins stage has finished

57 Views Asked by At

I have a Jenkins 2.401.1 server running. Inside it I am trying to create a declarative pipeline that should start a jar file. The pipeline builds the code in one Jenkins agent and by using 'stash', after the build is finished, the jar is copied to another agent. After this, the pipeline, tries to start the jar file with:

./startJar.sh

This sh file has the next content:

#!/bin/bash

nohup java -jar build/libs/leJar.jar > log/leJar.log 2>&1 &

exit 0

After the pipeline runs the step that executes'./startJar.sh' step, the jar appears to not start.

ps -ef

can tell this.

If I put a sleep after the step that starts the jar, the jar seems to be up and running and it stops when the pipeline stage is done. No error is thrown anywhere. Not even in 'journalctl'

Can someone please help?

1

There are 1 best solutions below

0
Ruslan On

try to use disown

java -jar build/libs/leJar.jar > log/leJar.log 2>&1 & disown

jenkins create sh script execute it and terminate shell process