Skip to content

Instantly share code, notes, and snippets.

@0x2539
Last active August 22, 2019 12:25
Show Gist options
  • Save 0x2539/bcb3d51dda55ea0f2719333e8c508895 to your computer and use it in GitHub Desktop.
Save 0x2539/bcb3d51dda55ea0f2719333e8c508895 to your computer and use it in GitHub Desktop.
Jenkins Setup
  1. Update JAVA_ARGS:
sudo vim /etc/default/jenkins
# update to:
# JAVA_ARGS="-Xmx1648m -XX:MaxPermSize=756m -Djava.awt.headless=true"
sudo /etc/init.d/jenkins restart
  1. Update the interface:
  2. Check the Blue Ocean (BlueOcean Aggregator) plugin
  3. Check Monitoring plugin
  4. Click Download now and install after restart
  5. Check Restart Jenkins when installation is complete and no jobs are running
  6. Go to main page
  7. Click Open Blue Ocean

Restart jenkins:

sudo su
service jenkins restart
# Ubuntu 18.04 LTS
# Master node
sudo groupadd docker
sudo usermod -aG docker jenkins # or Jenkins, depends on what name you chose
newgrp docker
sudo service docker restart
sudo service jenkins restart
# Ubuntu 18.04 LTS
# Agent (see https://linuxacademy.com/blog/devops/adding-a-jenkins-agent-node/)
echo "
#!/bin/bash
set -x
echo '--------------------------updating--------------------------'
sudo apt update
sudo apt install -y nodejs npm
mkdir -p /home/ubuntu/jenkins
# install java
echo '--------------------------installing java & psql--------------------------'
sudo apt install -y openjdk-8-jdk
sudo apt install -y postgresql-client
# install docker
echo '--------------------------installing docker, it will work after log out and relog in--------------------------'
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable'
sudo apt update
sudo apt install -y docker-ce
sudo usermod -aG docker ubuntu # ${USER}
sudo systemctl start docker
sudo systemctl status docker
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
" > /home/ubuntu/install.sh
chmod +x /home/ubuntu/install.sh
/home/ubuntu/install.sh
echo "...public key" >> /home/ubuntu/.ssh/authorized_keys
# Ubuntu 18.04 LTS
# Master node
echo "
#!/bin/bash
set -x
echo '--------------------------updating--------------------------'
sudo apt update
# install java jre
echo '--------------------------installing java--------------------------'
sudo apt install -y openjdk-8-jre-headless
# install Jenkins
echo '--------------------------installing jenkins--------------------------'
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install -y jenkins
sudo systemctl start jenkins
# jenkins password
echo '--------------------------jenkins password--------------------------'
echo '--------------------------jenkins password--------------------------' > output.txt
sudo bash -c 'cat /var/lib/jenkins/secrets/initialAdminPassword >> output.txt'
# jenkins ssh
echo '--------------------------jenkins ssh--------------------------'
sudo su - jenkins -c 'ssh-keygen'
echo '
--------------------------jenkins ssh ,append this to agent /home/ubuntu/.ssh/authorized_keys, make sure not to copy any line breaks--------------------------' >> output.txt
sudo bash -c 'cat /var/lib/jenkins/.ssh/id_rsa.pub >> output.txt'
echo '
--------------------------jenkins ssh private key, add it to jenkins web credentials (username (ubuntu) with private key (id_rsa))--------------------------' >> output.txt
sudo bash -c 'cat /var/lib/jenkins/.ssh/id_rsa >> output.txt'
" > /home/ubuntu/install.sh
chmod +x /home/ubuntu/install.sh
/home/ubuntu/install.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment