System Prerequisites
Before installing Jenkins, ensure your Linux environment has the necessary Java Runtime Environment (JRE) or Java Development Kit (JDK). Modern versions of Jenkins (starting from 2.357 and LTS 2.361.1) require Java 11 or Java 17.
Installing JDK 17
The following script automates the download and configuration of OpenJDK 17. We will use /opt/jdk as the installation directory.
# Create installation directories
mkdir -p /opt/software /opt/jdk
# Download OpenJDK 17
cd /opt/software
wget https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz
# Extract and create a symbolic link
tar -zxf openjdk-17.0.2_linux-x64_bin.tar.gz -C /opt/jdk/
ln -snf /opt/jdk/jdk-17.0.2 /opt/jdk/java17
# Configure environment variables
cat > /etc/profile.d/openjdk17.sh <<EOF
export JAVA_HOME=/opt/jdk/java17
export PATH=\$JAVA_HOME/bin:\$PATH
EOF
source /etc/profile.d/openjdk17.sh
# Verify the installation
java -version
System Dependencies
Jenkins requires specific libraries for UI rendering and version control integration. Install these using your package manager:
yum install -y fontconfig ttf-dejavu git
Jenkins Installation
For Linux distributions using RPM (like CentOS or RHEL), you can download the package from a reliable mirror such as Tsinghua University's open-source mirror to speed up the process.
# Download the specific Jenkins RPM package
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.462-1.1.noarch.rpm
# Install the package
rpm -ivh jenkins-2.462-1.1.noarch.rpm
Service Management
Once installed, reload the systemd manager configuration and enable the service to start automatical on boot.
systemctl daemon-reload
systemctl enable jenkins
systemctl start jenkins
Initial Configuration
Accessing the Admin Password
During the first launch, Jenkins generates a unique temporary password. Retrieve it using the following command to unlock the web interface:
cat /var/lib/jenkins/secrets/initialAdminPassword
Optimizing Update Sources
To improve plugin download speeds, replace the default update site URL with a local mirror. Navigate to Manage Jenkins > Plugins > Advanced and set the Update Site URL to:
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json#### Localization (Optional)
If you require a specific language interface, such as Chinese, search for and install the "Localization: Chinese (Simplified)" plugin within the Plugin Manager. Restart Jenkins after the installation completes to apply the changes.