Skip to content

Instantly share code, notes, and snippets.

@akiltipu
Last active March 9, 2024 19:28
Show Gist options
  • Save akiltipu/b2f56247878d794f1c3321579646254e to your computer and use it in GitHub Desktop.
Save akiltipu/b2f56247878d794f1c3321579646254e to your computer and use it in GitHub Desktop.
Install Jenkins on Ubuntu server
#!/bin/bash
# Update the package list
sudo apt update
# Add Jenkins repository key
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
#Then add a Jenkins apt repository entry:
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
# Update the package list
sudo apt update
# Install Java (Jenkins requires Java)
sudo apt-get install fontconfig openjdk-17-jre -y
# Add Jenkins repository to sources list
# echo "deb http://pkg.jenkins.io/debian-stable binary/" | sudo tee -a /etc/apt/sources.list.d/jenkins.list
# Update package list again to include Jenkins repository
sudo apt update
# Install Jenkins
sudo apt install -y jenkins
# Start Jenkins service
sudo systemctl start jenkins
# Enable Jenkins to start on boot
sudo systemctl enable jenkins
# Display initial Jenkins admin password
echo "Waiting for Jenkins to start..."
sleep 60 # Wait for Jenkins to fully start (adjust if needed)
# Retrieve the initial admin password
JENKINS_PASSWORD=$(sudo cat /var/lib/jenkins/secrets/initialAdminPassword)
echo "Jenkins initial admin password: $JENKINS_PASSWORD"
echo "Access Jenkins at http://your-server-ip:8080"
# Open the firewall to allow access to Jenkins
sudo ufw allow 8080
# Display Jenkins status
sudo systemctl status jenkins | cat
@akiltipu
Copy link
Author

akiltipu commented Mar 9, 2024

To install Jenkins on your Ubuntu server, navigate to your server environment and execute the following command by copying and pasting it:

wget https://gist.githubusercontent.com/akiltipu/b2f56247878d794f1c3321579646254e/raw/4cb7ff3da390617520480101c7418049bf6dadfe/install_jenkins.sh
chmod +x install_jenkins.sh
./install_jenkins.sh

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