Skip to content

Instantly share code, notes, and snippets.

@aliselcuk
Last active March 26, 2020 01:51
Show Gist options
  • Save aliselcuk/68bdb34140d36970be0beab70a4be167 to your computer and use it in GitHub Desktop.
Save aliselcuk/68bdb34140d36970be0beab70a4be167 to your computer and use it in GitHub Desktop.
Install & Configure Jenkins on Debian/Ubuntu
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-get update
sudo apt-get install default-jre
sudo apt-get install jenkins
su - jenkins
ssh-keygen -t rsa -b 4096 -C "[email protected]"
cat ~/.ssh/id_rsa.pub # copy
# ON Web Server (X)
adduser jenkins
usermod -aG sudo jenkins
su - jenkins
mkdir ~/.ssh
nano ~/.ssh/authorized_keys # paste
exit # back to root
nano /etc/sudoers.d/jenkins
echo 'jenkins ALL=(ALL) NOPASSWD: /usr/sbin/service nginx' >> /etc/sudoers.d/jenkins
echo 'jenkins ALL=(ALL) NOPASSWD: /usr/sbin/service php*-fpm' >> /etc/sudoers.d/jenkins
echo 'jenkins ALL=(ALL) NOPASSWD: /bin/chmod 775 -R /sites/website.com/staging/current/storage' >> /etc/sudoers.d/jenkins
# give SUDO and SSH to jenkins user on your Web Server, (narrow this down!)
echo 'jenkins ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/jenkins
# on jenkins:
# - install Publish over SSH plugin
# - configure system > Publish over SSH > key & server setup
# - create jenkins project > freestyle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment