Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Created November 10, 2018 11:20
Show Gist options
  • Save unakatsuo/d4711f52a0ab0b9bc8010018149a7e84 to your computer and use it in GitHub Desktop.
Save unakatsuo/d4711f52a0ab0b9bc8010018149a7e84 to your computer and use it in GitHub Desktop.
systemd Jenkins JNLP Slave service
JENKINS_URL=http://192.168.1.57:8080
JENKINS_WORKSPACE=/home/jenkins/workspace
JENKINS_NODE=node1
# Place to /etc/systemd/system/ or /usr/lib/systemd/system/.
[Unit]
Description=Jenkins JNLP Slave service
After=network.target
[Service]
Type=simple
Environment=LANG=C
EnvironmentFile=-/etc/sysconfig/jenkins-slave
WorkingDirectory=${JENKINS_WORKSPACE}
ExecStartPre=/usr/bin/curl --fail -s -o ${JENKINS_WORKSPACE}/slave.jar ${JENKINS_URL}/jnlpJars/slave.jar
ExecStart=/usr/bin/java -jar ${JENKINS_WORKSPACE}/slave.jar -jnlpUrl ${JENKINS_URL}/computer/${JENKINS_NODE}/slave-agent.jnlp
Restart=on-failure
RestartSec=30s
[Install]
WantedBy=multi-user.target
@fabricat
Copy link

Cool, many thanks.
I tried implementing that but it seems that WorkingDirectory does not allow variables :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment