一、环境软件安装
- sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
- sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
- sudo yum install jenkins
- sudo yum install java
5.所有安装完毕后,启动服务(当然也有其他启动方式)
代码语言:javascript复制service jenkins start
代码语言:javascript复制service nginx restart
二、相关内容介绍(如果第一步进行完毕的话)
- 日志: /var/log/jenkins
- 配置文件:/etc/sysconfig/jenkins
- 服务配置文件:/etc/init.d/jenkins
- Jenkins源文件地址:/var/cache/jenkins/war/
- Jenkins War包地址:/usr/lib/jenkins/jenkins.war
三、配置nginx访问,以下贴出源码
备注:了解nginx知识参考: https://cloud.tencent.com/developer/article/1747597
代码语言:javascript复制server {
listen 80; # Listen on port 80 for IPv4 requests
server_name www.wangzhi.com;
access_log /var/log/nginx/jenkins_access.log;
error_log /var/log/nginx/jenkins_error.log;
location ~ ^/static/[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]/(.*)$ {
#E.g /static/12345678/css/something.css will become /css/something.css
rewrite "^/static/[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]/(.*)" /$1 last;
}
location @jenkins {
sendfile off;
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location / {
root /var/cache/jenkins/war/;
try_files $uri @jenkins;
}
}
四、问题处理
1.如果报错:Public key for jenkins-2.237-1.1.noarch.rpm is not installed,
下载最新签名
cd /etc/pki/rpm-gpg
wget http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
处理后重新安装进jenkins
2.如果运行jenkins提示权限问题
参考:CentOS7 修改Jenkins以root用户运行
https://blog.csdn.net/jeikerxiao/article/details/80768949