Last active
February 20, 2024 11:53
-
-
Save cidermole/eccc5896658e4a99e674e20e80aafcb2 to your computer and use it in GitHub Desktop.
Systemd service file for Jenkins agent on Ubuntu 20.04 Focal Fossa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Steps to install Jenkins Agent using JNLP connection on Ubuntu 20.04 Focal Fossa | |
# | |
# * create an Agent node on the web GUI: https://wiki.jenkins.io/display/JENKINS/Step+by+step+guide+to+set+up+master+and+agent+machines+on+Windows | |
# * $ sudo apt-get install -y openjdk-14-jre-headless | |
# * $ sudo adduser jenkins | |
# * $ curl http://jenkins-master.internal/jnlpJars/agent.jar -o /home/jenkins/agent.jar | |
# * create systemd service: place this file in /lib/systemd/system/jenkins-agent.service | |
# * $ sudo systemctl enable myservice | |
# * $ sudo systemctl start jenkins-agent | |
[Unit] | |
Description=Jenkins Agent | |
After=network.target | |
Requires=network.target | |
[Service] | |
Type=simple | |
# optional file to provide environment variables (e.g. http_proxy, https_proxy): | |
#EnvironmentFile=/etc/sysconfig/jenkins | |
# TODO: adapt -jnlpUrl und -secret, as found on the web GUI: Jenkins > Nodes > ... | |
ExecStart=/usr/bin/java -jar /home/jenkins/agent.jar -jnlpUrl http://jenkins-master.internal:8080/computer/Linux/slave-agent.jnlp -secret 6bd5082ce1531212341234123412341234123412341234123412341234764898 -workDir "/home/jenkins" | |
Restart=always | |
User=jenkins | |
RestartSec=20 | |
[Install] | |
WantedBy=multi-user.target |
Many thanks for this. Very useful.
Thanks a lot. You saved my day.
Just a tip, if there is a '%' symbol in your .service
file, it is necessary to insert an additional '%' to escape it.
Thanks @cidermole for the service file and @asuna for the tip! It worked! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice man!
but how to use user jenkins without passwd?