Debian update overwrites environment settings

160 views
Skip to first unread message

Jochen Wiedmann

unread,
Jan 2, 2024, 2:22:51 PMJan 2
to Jenkins Users

Hi,

I am using the Jenkins Debian packages from


to install, and update Jenkins. In general, I'm quite happy with that. There is one exception, though:

My setup requires changing of two environment variables, JENKINS_PORT, and JAVA_HOME. Right now, I have configured those by editing jenkins.service. In other words, I am advising systemd to set the proper values.

The problem with that: Any update of Jenkins (of which there are quite a few, thankfully) replaces the jenkins.service file, thus overwriting my changes. In other words: After each update, I need to reapply my changes to jenkins.service.

Is there any better location for those values, that survives updates?

Thanks,

Jochen


Mark Waite

unread,
Jan 2, 2024, 2:30:08 PMJan 2
to Jenkins Users
There is a better location for those values and it will survive updates.  The "Managing systemd services" page describes the "systemctl edit jenkins" command that creates a local copy of the overrides file .  That copy is preserved across upgrades.

Mark Waite
 

Dirk Heinrichs

unread,
Jan 3, 2024, 1:33:51 AMJan 3
to jenkins...@googlegroups.com
Am Dienstag, dem 02.01.2024 um 11:30 -0800 schrieb Mark Waite:

There is a better location for those values and it will survive updates.  The"Managing systemd services" page describes the "systemctl edit jenkins" command that creates a local copy of the overrides file .  That copy is preserved across upgrades.

Or, if you prefer the manual way or use a provisioning tool like Puppet or Salt, you can create a directory under "/etc/systemd/system/" with the same name as the service file and an appended ".d" and place any number of override files inside, with a ".conf" extension. Note that if you want to change one of the "Exec*" values, you need to empty it first, like

ExecStart=
ExecStart=/path/to/new/command options

See systemd.unit(5) and systemd.service(5) for the details.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

Jochen Wiedmann

unread,
Jan 10, 2024, 5:43:46 PMJan 10
to Jenkins Users

Thanks, Mark,

your suggestion works perfectly. For the record, I now have a file /etc/systemd/system/jenkins.service.d/override.conf with the following content:

    [Service]
    Environment="JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-amd64"
    Environment="JENKINS_PORT=8008"

This changes both the JVM, that is used to run Jenkins, and the port number.

Jochen
Reply all
Reply to author
Forward
0 new messages