My Bazel server used to die mysteriously after the Jenkins build finishes. This is bad, as I want to keep it alive for performance reasons.

The culprit turned out to be the ProcessTreeKiller in Jenkins, responsible for killing all background processes spawned as part of a build. It turns out to be pretty smart, as even the usual hack of nohup setsid didn’t help.

The solution is to set a magic value for BUILD_ID:

BUILD_ID=dontKillMe bazel build ...