-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstall_jenkins_on_ubuntu.sh
55 lines (39 loc) · 1.6 KB
/
install_jenkins_on_ubuntu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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 -e "===========Initial Admin Password ===========\n"
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
echo -e "\n"
echo -e "===========Initial Admin 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