I have four books that on Jenkins and have read numerous posts on the Net that discuss weird Jenkins details and internals (more than I ever wished to know about), but none that explains what the file
$JENKINS_HOME/.owner does (even though they include listings like this ). I found out about it recently because I was greeted by the message:
Jenkins detected that you appear to be running more than one instance of Jenkins that share the same home directory. This greatly confuses Jenkins and you will likely experience strange behaviours, so please correct the situation. This Jenkins: 1232342241 contextPath="" at email@example.com Other Jenkins: 863352860 contextPath="" at firstname.lastname@example.org [Ignore this problem and keep using Jenkins anyway]
Indeed it appears that Jenkins, after initialisation, does run a test to check whether another process already runs from the same directory. When the check is run, it creates the file
.owner part of the name is hardcoded.
Even more interesting is the fact, that in order to avoid having the two processes write information on
.owner at the same time, randomises when the process is going to write on the file, so even if both processes start at the same time, chances that their writes coincide are slim.
The mechanism is simple. This class occasionally updates a known file inside the hudson home directory, and whenever it does so, it monitors the timestamp of the file to make sure no one else is updating this file. In this way, while we cannot detect the problem right away, within a reasonable time frame we can detect the collision.
You may want to keep that in mind, especially in cases when you’re greeted by the above message but know for a fact that a second process is not running. Some abrupt ending of the previous process occurred and you did not take notice. Or indeed a second process is messing with your CI