Skip to content

Instantly share code, notes, and snippets.

@boktai1000
Created April 11, 2019 22:54
Show Gist options
  • Save boktai1000/1ee5e5d90a8855a37c069b7981e07fc2 to your computer and use it in GitHub Desktop.
Save boktai1000/1ee5e5d90a8855a37c069b7981e07fc2 to your computer and use it in GitHub Desktop.
# You can run this script directly with the following command
# curl -s https://gist.githubusercontent.com/boktai1000/1ee5e5d90a8855a37c069b7981e07fc2/raw/57e09087028d553a1b7ba510de1c6337ce6ea662/el7-install-jenkins-native.sh | sudo bash
# https://www.hugeserver.com/kb/how-install-jenkins-centos7/
# https://www.linuxtechi.com/install-configure-jenkins-on-centos-7-rhel-7/
# https://computingforgeeks.com/how-to-install-jenkins-server-stable-on-centos-7/
# https://www.vultr.com/docs/how-to-install-jenkins-on-centos-7
# Set Variables
yourip=$(hostname -I | awk '{print $1}')
# Add Jenkins Repository
curl https://pkg.jenkins.io/redhat-stable/jenkins.repo > /etc/yum.repos.d/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
# Install Java and Jenkins
yum install -y java-1.8.0-openjdk jenkins
# Check and Validate Java Version
java -version
# Start and Enable Jenkins Service
systemctl start jenkins
systemctl enable jenkins
systemctl status jenkins
# Open Firewall
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --reload
# Echo information on what the output beneath this is for
echo Jenkins starting and generating initial Admin Password...
# https://stackoverflow.com/questions/2379829/while-loop-to-test-if-a-file-exists-in-bash
# Wait for file to be created, then Display initial Admin Password
# Alternatively run "grep -A 5 password /var/log/jenkins/jenkins.log"
while [ ! -f /var/lib/jenkins/secrets/initialAdminPassword ]
do
sleep 2
done
cat /var/lib/jenkins/secrets/initialAdminPassword
# Echo information on what the output beneath this is for
echo initial Admin Password generated above.
# Echo a reminder to CLI on how to connect to Tomcat
echo Continue Jenkins setup at http://$yourip:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment