Last active
June 28, 2018 18:03
-
-
Save brianv0/579c3263c64cb5b7f8105cffad45890c to your computer and use it in GitHub Desktop.
Jenkins Setup
This file contains hidden or 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
#!/bin/bash | |
JENKINS_USER=jenkins | |
JENKINS_URL=https://example.com/jenkins | |
WORKER_NAME=jenkins-docker01 | |
yum update -y && yum install -y java-1.8.0-openjdk | |
mkdir /usr/share/jenkins | |
chmod 755 /usr/share/jenkins | |
cat >> /usr/lib/systemd/system/jenkins.service <<EOF | |
[Unit] | |
Description=Jenkins Slave | |
Requires=network.target | |
After=multi-user.target | |
[Service] | |
PermissionsStartOnly=true | |
Environment=URL=${JENKINS_URL} | |
Environment=AGENT_NAME=${WORKER_NAME} | |
User=${JENKINS_USER} | |
Type=simple | |
ExecStartPre=/usr/bin/curl -o /usr/share/jenkins/slave.jar \${URL}/jnlpJars/slave.jar | |
ExecStart=/usr/bin/java -jar /usr/share/jenkins/slave.jar -jnlpUrl \${URL}/computer/\${AGENT_NAME}/slave-agent.jnlp -workDir "/home/jenkins" | |
Restart=always | |
RestartSec=15 | |
StartLimitInterval=0 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl daemon-reload | |
systemctl start jenkins | |
systemctl enable jenkins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment