#---------------------------------------------------------------------------------------------------------
#前置作業
yum install -y wget
systemctl stop firewalld
systemctl disable firewalld
#---------------------------------------------------------------------------------------------------------
#安裝openjdk
yum install -y java-11-openjdk
#---------------------------------------------------------------------------------------------------------
#設定jenkins的yum repo
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
#---------------------------------------------------------------------------------------------------------
#安裝jenkins
yum install -y jenkins
#---------------------------------------------------------------------------------------------------------
#設定jenkins (以下步驟非必要,可以跳過)
4.jenkins預設是8080 port,可以利用以下設定檔去改變port
vi /etc/sysconfig/jenkins
加入以下設定可以預防發生Out of memory情況
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:PermSize=128M -XX:PermSize=256M"
#---------------------------------------------------------------------------------------------------------
#啟動jenkins
systemctl start jenkins
systemctl enable jenkins
#---------------------------------------------------------------------------------------------------------
#最後打開網頁http://IP:8080/,一開始需要解鎖jenkins,密碼放在
cat /var/lib/jenkins/secrets/initialAdminPassword
#---------------------------------------------------------------------------------------------------------
補充:
記得要校時,否則jenkins的schedule job可能會異常。
sudo apt-get update
sudo apt install openjdk-11-jdk -y
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
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
sudo apt-get update
sudo apt-get install -y jenkins
systemctl start jenkins
systemctl enable jenkins
sudo timedatectl set-timezone Asia/Taipei
sudo timedatectl set-ntp yes
sudo systemctl enable systemd-timesyncd
sudo systemctl restart systemd-timesyncd
sudo systemctl status systemd-timesyncd
sudo timedatectl