「Jenkins」- 安装(CentOS、Debian、Ubuntu)

  CREATED BY JENKINSBOT

依赖安装

安装 JDK/JRE 包(Jenkins 使用 Java 开发的,需要安装运行环境):

# Debian GNU/Linux 10 (buster)
apt-get install -y openjdk-11-jre

on Ubuntu 20.04

Installing Jenkins/Linux

Weekly release:

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins

on CentOS 7.0

RedHat Linux RPM packages for Jenkins

# 12/27/2018

yum install wget
yum install java-1.8.0-openjdk.x86_64

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key

yum install jenkins

访问服务器地址,开始配置你的的Jenkins,首页是让你输入初始密码,并告诉你初时密码所在的文件。

on Debian 10

Debian Jenkins Packages

Jenkins Regular releases (Weekly)

# 08/19/2020

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | apt-key add -
echo 'deb https://pkg.jenkins.io/debian binary/' > /etc/apt/sources.list.d/jenkins.list
apt-get update

apt-get install -y jenkins
/lib/systemd/systemd-sysv-install enable jenkins
systemctl start jenkins.service

# 浏览器访问 http://127.0.0.1:8080 以进行初始化

on Debian 8.2

Debian/Ubuntu

# 04/04/2019

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | apt-key add -
echo "deb http://pkg.jenkins.io/debian-stable binary/" > /etc/apt/sources.list.d/jenkins.list

apt-get update
apt-get install -y jenkins

# 如果你要手动指定自己的JDK版
# 修改/etc/default/jenkin文件,追加如下行在开始
JAVA_HOME="/opt/openjdk-1.8"
PATH="$JAVA_HOME/bin:$PATH"

with Docker Compose

Jenkins/User Handbook/Docker

如下配置,仅供参考:

version: '3'
services:
  jenkins-master:
    image: 'jenkins/jenkins:2.340-jdk8'
    container_name: jenkins-master
    environment:
      - JAVA_OPTS="-Duser.timezone=Asia/Shanghai -Dhudson.model.DirectoryBrowserSupport.CSP=''"
    volumes:
      - /etc/localtime:/etc/localtime
      - ./data:/var/jenkins_home
    ports:
      - 8088:8080
      - 50000:50000
    restart: always

参考文献

Jenkins download and deployment
Installing Jenkins/Linux