MENU

Centos7 安装配置 Jenkins

August 5, 2017 • Read: 874 • Linux

安装 Jenkins

确定是否已经安装 JDK8(官方推荐使用 JDK8)。

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

导入jenkins仓库

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

执行yum install jenkins开始安装。

设置开机启动,并启动jenkins:

systemctl daemon-reload
systemctl enable jenkins
systemctl start jenkins

配置Jenkins

修改默认端口:

vim /etc/sysconfig/jenkins

配置nginx

配置二级域名http://ci.wangxs.cn/

server {
    listen 80;
    server_name ci.wangxs.cn;

    location / {
      proxy_set_header        Host $host:$server_port;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      proxy_pass          http://127.0.0.1:9090;
      proxy_read_timeout  90;

      proxy_http_version 1.1;
      proxy_request_buffering off;
    }
    access_log  /var/log/nginx/ci_wangxs_cn_access.log combined;
}

本来打算使用二级目录,可以走https;但是,Jenkins打开时会跳转到登陆页面,登陆页跳转时没带上层目录,直接跳到了/login,网上有人用302跳转的方式解决;

location /jenkins {
    return 302 http://dev.server.com:9090; 
}

安装插件

打开链接,按照提示填写解锁密码:

image

点击左边安装建议插件:

image

安装插件:

image

创建管理员用户:

image

保存并进入(点击save and finish):

image

如果忘记用户名密码,可以使用amdin用户登陆,admin登陆密码在/var/lib/jenkins/secrets/initialAdminPassword中。

Last Modified: July 21, 2019