systemd service startup script worked in 16.04 but throws an error in 18.04

I have the following jenkins-agent.service file placed in /etc/systemd/system/:

[Unit]
Description=Jenkins agent
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/java -jar /home/jenkins/jenkins/Agent/agent.jar -jnlpUrl http://my.jenkins.server.com:8087/jenkins/computer/Ubuntu%2064-bit/slave-agent.jnlp -secret d1ac22621ad4c460e5f8de4f564345fa7cdb2bea1d26b6f17230451a37a08e7e -workDir "/home/jenkins/jenkins"
Restart=always

[Install]
Wants=network-online.target
WantedBy=multi-user.target

It's registered with systemd and worked perfectly to start the Jenkins agent process on system boot. But I've just updated to 18.04, and now this script throws a syntax error:

systemd-analyze verify /etc/systemd/system/jenkins-agent.service
File /lib/systemd/system/systemd-journald.service:36 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
/etc/systemd/system/jenkins-agent.service:7: Failed to resolve unit specifiers on http://my.jenkins.sever.com:8087/jenkins/computer/Ubuntu%2064-bit/slave-agent.jnlp: Invalid slot
jenkins-agent.service: Failed to create jenkins-agent.service/start: Unit jenkins-agent.service is not loaded properly: Exec format error.
Attempted to remove disk file system, and we can't allow that.

How can this be fixed? I don't understand what's wrong. It says the problem is with the Unit section, so I've checked that /lib/systemd/system/network-online.target exists (it does).


The problem is the use of % in here:

.../Ubuntu%2064-bit/...
#         ^

SystemD uses % as the keyword for various internal format specifiers, and in ExecStart (and brothers) those format specifiers can be used for dynamic replacement of values. As it can't interpret %2 as a proper specifier, you are getting:

Exec format error

You need to escape the % with another %:

.../Ubuntu%%2064-bit/...