Last active
September 28, 2018 08:38
-
-
Save johanvergeer/eea63deccae6536a77b609b9493c31a5 to your computer and use it in GitHub Desktop.
Docker Jenkins
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
cd /usr/local/bin | |
wget https://github.com/docker/compose/releases/download/1.13.0/docker-compose-Linux-x86_64 | |
mv docker-compose* docker-compose | |
chmod +x docker-compose |
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
sudo -s | |
mkdir -p /usr/local/jenkins | |
cd /usr/local/jenkins | |
wget https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.7/swarm-client-3.7.jar # Make sure you're using the correct version! | |
touch swarm.sh | |
chmod +x swarm.sh |
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
cd /usr/local/bin | |
wget https://github.com/tsenart/vegeta/releases/download/v6.3.0/vegeta-v6.3.0-linux-amd64.tar.gz | |
tar xf *.gz | |
rm *.gz |
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
# Install Docker | |
curl -sSL https://get.docker.com/ | sh | |
# Add user to Docker group... | |
sudo usermod -aG docker $(whoami) |
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
sudo apt install openjdk-8-jdk |
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
# This should go into /etc/systemd/system/jenkins.service | |
[Unit] | |
Description=Jenkins | |
After=network.target | |
[Service] | |
User=$(whoami) # Replace this with a valid username | |
Restart=always | |
Type=simple | |
ExecStart=/usr/local/jenkins/swarm.sh | |
[Install] | |
WantedBy=multi-user.target |
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
mkdir ~/jenkins | |
cd ~/jenkins | |
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 -v $(pwd):/var/jenkins_home --restart always jenkins/jenkins:lts |
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
systemctl enable jenkins | |
systemctl start jenkins |
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
# This should go into /usr/local/jenkins/swarm.sh | |
#!/bin/bash | |
cd $(dirname $0) | |
JENKINS_IP="10.0.0.1" | |
USERNAME="admin" | |
PASSWORD="12345678" | |
# $(hostname) will be the name that appears in Jenkins UI | |
# -executors is the number of concurrent tasks that it can handle from Jenkins | |
# -labels is the name of the node | |
# -master is the ip addess of the Jenkins Master | |
java -jar swarm-client-3.7.jar -name "$(hostname)" -executors 8 -labels docker -master "http://$JENKINS_IP:8080" -username "$USERNAME" -password "$PASSWORD" -fsroot /tmp |
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
# ...and switch to the new group | |
newgrp docker |
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
docker logs -f jenkins |
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
me@jenkins-agent-1:/usr/local/jenkins$ ./swarm.sh | |
Sep 28, 2018 8:22:44 AM hudson.plugins.swarm.Client main | |
INFO: Client.main invoked with: [-name jenkins-agent-1 -executors 8 -labels docker -master http://$jenkins_master_ip:8080 -username $username -password $password -fsroot /tmp] | |
Sep 28, 2018 8:22:45 AM hudson.plugins.swarm.Client run | |
INFO: Discovering Jenkins master | |
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". | |
SLF4J: Defaulting to no-operation (NOP) logger implementation | |
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. | |
Sep 28, 2018 8:22:45 AM hudson.plugins.swarm.Client run | |
INFO: Attempting to connect to http://$jenkins_master_ip:8080/ secret with ID anid | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main createEngine | |
INFO: Setting up agent: jenkins-agent-1-5cbaa68d | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main$CuiListener <init> | |
INFO: Jenkins agent is running in headless mode. | |
Sep 28, 2018 8:22:46 AM hudson.remoting.Engine startEngine | |
WARNING: No Working Directory. Using the legacy JAR Cache location: /home/me/.jenkins/cache/jars | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Locating server among [http://ip_address:8080/] | |
Sep 28, 2018 8:22:46 AM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve | |
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping] | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Agent discovery successful | |
Agent address: jenkins_agent_address | |
Agent port: 50000 | |
Identity: secret | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Handshaking | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Connecting to 188.166.10.76:50000 | |
Sep 28, 2018 8:22:46 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Trying protocol: JNLP4-connect | |
Sep 28, 2018 8:22:47 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Remote identity confirmed: secret | |
Sep 28, 2018 8:22:48 AM hudson.remoting.jnlp.Main$CuiListener status | |
INFO: Connected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment