Trying to upgrade Jenkins, which has been installed on Ubuntu as a deb package from pkg.jenkins.io, results in the following error if Jenkins has been set to to not run standalone in /etc/default/jenkins:
Setting up jenkins (2.164.3) ...
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
* jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-05-12 15:00:08 CEST; 37ms ago
Process: 22350 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)
May 12 15:00:08 server07.pepsoft.org systemd: Starting LSB: Start Jenkins at boot time...
May 12 15:00:08 server07.pepsoft.org jenkins: Not configured to run standalone
May 12 15:00:08 server07.pepsoft.org systemd: jenkins.service: Control process exited, code=exited status=1
May 12 15:00:08 server07.pepsoft.org systemd: Failed to start LSB: Start Jenkins at boot time.
May 12 15:00:08 server07.pepsoft.org systemd: jenkins.service: Unit entered failed state.
May 12 15:00:08 server07.pepsoft.org systemd: jenkins.service: Failed with result 'exit-code'.
dpkg: error processing package jenkins (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
/etc/default/jenkins contains the following lines:
# set this to false if you don't want Jenkins to run by itself
# in this set up, you are expected to provide a servlet container
# to host jenkins.
This is because I have configured my pre-existing Tomcat container to run Jenkins because I don't want a separate Java process to take up the limited resources of my VPS.
If I change the setting to true, the upgrade does succeed.
It seems that the upgrade script should take that setting into account, and/or check whether the service is running to begin with, before trying to stop and start it.