安装最新版Jenkins
添加jenkins yum源:
- sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
- sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
- sudo yum install jenkins
安装稳定版Jenkins
There is also a LTS YUM repository for the LTS Release Line
- sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
- sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
- sudo yum install jenkins
安装Java
Jenkins requires Java in order to run, yet certain distros don't include this by default. To install the Open Java Development Kit (OpenJDK) run the following:
sudo yum install java
Note: 如果Java/Jdk安装到其他目录,使用软连接命令ln -s XXXX/bin/java /usr/bin/java;或者编辑:vi /etc/init.d/jenkins中”candidates=“选项
目录说明
- 日志: /var/log/jenkins
- 配置文件:/etc/sysconfig/jenkins
- 服务配置文件:/etc/init.d/jenkins
- Jenkins源文件地址:/var/cache/jenkins/war/
- Jenkins War包地址:/usr/lib/jenkins/jenkins.war
Nginx配置Jenkins
server {listen 8090; # Listen on port 80 for IPv4 requestsserver_name build.yourdomain.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]\/(.*)$ {#rewrite all static files into requests to the root#E.g /static/12345678/css/something.css will become /css/something.cssrewrite "^/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 /userContent {#have nginx handle all the static requests to the userContent folder files#note : This is the $JENKINS_HOME dirroot /var/lib/jenkins/;if (!-f $request_filename){#this file does not exist, might be a directory or a /**view** urlrewrite (.*) /$1 last;break;}sendfile on;}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;#this is the maximum upload sizeclient_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;}}
Note: 启动Nginx之后,不要忘了启动Jenkins!