Tuesday, April 2, 2013

Run background java process from Jenkins

Jenkins is using mechanism to detect spawned processes and kill them after finishing job, so if you will just start such ad-hoc background daemon process, Jenkins will kill it with warning:


Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information

Fortunately, there is easy hack to tell Jenkins ignore such process, just create fake BUILD_ID and start your application, for example, this can be entered into Execute shell build step:

BUILD_ID=dontKillMe nohup java -jar test.jar &

Warning is still there, but process should be fine and running. There is more about it here.

18 comments:

  1. Thanks a lot! I spent 1 day for this problem.

    ReplyDelete
  2. Where i need to give this command, at Jenkins server or client...
    i spent almost one day so far but still no luck.. please give quick answer...

    ReplyDelete
  3. give in batch file ex: set BUILD_ID=dontKillMe nohup java -jar test.jar &
    its worked...

    ReplyDelete
  4. Thanks, it also saved my day :)

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. if you put nohup java -jar test.jar & in another shell script, call start_up.sh, and execute shell in jenkins: BUILD_ID=dontKillMe nohup start_up.sh &. It DON NOT work! I don't know why and wonder how to fix it..

    ReplyDelete
  7. for anyone else, I had to put the dontkillme line ABOVE the background task in windows ie :

    set BUILD_ID=dontKillMe
    @start /b cmd /c bundle exec thin start

    this problem has wasted me nearly an entire day today :(

    ReplyDelete
  8. Administrations, for example, background checks are more open. Through this article, I am will confer to you the best background check organization accessible on the net.best background investigation services

    ReplyDelete
  9. Excellent and very exciting site. Love to watch. Keep Rocking. dungeons and dragons dice

    ReplyDelete
  10. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. dnd dice

    ReplyDelete
  11. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. toro scarpe nere

    ReplyDelete
  12. Therefore, the service provider will charge you based on the type of fault in your device or machine. Therefore, you may want to ask the pro about how they figure out the service charges Santa Clarita Sub Zero Refrigerator Repair Service

    ReplyDelete
  13. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. Javascript Commission Bot Review

    ReplyDelete
  14. They should then give reasons why your selection is or is not the right selection for your needs and offer alternatives which they feel could be better for the job. seal coat

    ReplyDelete
  15. Thanks i literally spent 1 half day to get this done

    ReplyDelete