安装Jenkins : yum install jenkins 有时会报 找不到
可以换种方式(安装jenkins之前必须自己安装JDK)
安装jdk
$ java -version
$ sudo yum install java-1.7.0-openjdk
一、下载jenkins包:
Wget http://pkg.jenkins-ci.org/redhat-stable/ jenkins-1.658-1.1.noarch.rpm
二、安装jenkins:
sudo rpm -ivh jenkins-1.658-1.1.noarch.rpm
三、启动jenkins(默认端口8080)
sudo /sbin/service jenkins start
jenkins安装成功:在/usr/lib/jenkins目录下看到jenkins.war表示安装成功
四、启动jenkins(默认端口8080)
sudo /sbin/service jenkins start
或者
sudo service jenkins start
如果启动失败报错:
进入vim /etc/init.d/jenkins
需要注释掉下面的java指向,留下自己安装的:
# Search usable Java. We do this because various reports indicated
# that /usr/bin/java may not always point to Java >= 1.6
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
candidates="
#/etc/alternatives/java
#/usr/lib/jvm/java-1.6.0/bin/java
#/usr/lib/jvm/jre-1.6.0/bin/java
#/usr/lib/jvm/java-1.7.0/bin/java
#/usr/lib/jvm/jre-1.7.0/bin/java
#/usr/lib/jvm/java-1.8.0/bin/java
#/usr/lib/jvm/jre-1.8.0/bin/java
/usr/java/jdk1.7.0_65/bin/java
"
还可以升级自己的jdk解决这个问题。防火墙规则
配置防火墙规则
firewall-cmd –zone=public –add-port=8080/tcp –permanent
firewall-cmd –zone=public –add-service=http –permanent
firewall-cmd –reload
firewall-cmd –list-all
五、更改jenkins的配置vi /etc/sysconfig/jenkins ,“端口”,“JENKINS_HOME”等都可以在这里配置
## Path: Development/Jenkins
## Description: Jenkins Continuous Integration Server
## Type: string
## Default: "/var/lib/jenkins"
## ServiceRestart: jenkins
#
# Directory where Jenkins store its configuration and working
# files (checkouts, build reports, artifacts, ...).
#
JENKINS_HOME="/var/lib/jenkins"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Java executable to run Jenkins
# When left empty, we'll try to find the suitable Java.
#
JENKINS_JAVA_CMD=""
## Type: string
## Default: "jenkins"
## ServiceRestart: jenkins
#
# Unix user account that runs the Jenkins daemon
# Be careful when you change this, as you need to update
# permissions of $JENKINS_HOME and /var/log/jenkins.
#
JENKINS_USER="jenkins"
## Type: string
## Default: "false"
## ServiceRestart: jenkins
#
# Whether to skip potentially long-running chown at the
# $JENKINS_HOME location. Do not enable this, "true", unless
# you know what you're doing. See JENKINS-23273.
#
#JENKINS_INSTALL_SKIP_CHOWN="false"
## Type: string
## Default: "-Djava.awt.headless=true"
## ServiceRestart: jenkins
#
# Options to pass to java when running Jenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
## Type: integer(0:65535)
## Default: 8080
## ServiceRestart: jenkins
#
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for HTTP requests.
# Default is all interfaces (0.0.0.0).
#
JENKINS_LISTEN_ADDRESS=""
## Type: integer(0:65535)
## Default: ""
## ServiceRestart: jenkins
#
# HTTPS port Jenkins is listening on.
# Default is disabled.
#
JENKINS_HTTPS_PORT=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Path to the keystore in JKS format (as created by the JDK 'keytool').
# Default is disabled.
#
JENKINS_HTTPS_KEYSTORE=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE.
# Default is disabled.
#
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for HTTPS requests.
# Default is disabled.
#
JENKINS_HTTPS_LISTEN_ADDRESS=""
## Type: integer(0:65535)
## Default: 8009
## ServiceRestart: jenkins
#
# Ajp13 Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_AJP_PORT="8009"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for Ajp13 requests.
# Default is all interfaces (0.0.0.0).
#
JENKINS_AJP_LISTEN_ADDRESS=""
## Type: integer(1:9)
## Default: 5
## ServiceRestart: jenkins
#
# Debug level for logs -- the higher the value, the more verbose.
# 5 is INFO.
#
JENKINS_DEBUG_LEVEL="5"
## Type: yesno
## Default: no
## ServiceRestart: jenkins
#
# Whether to enable access logging or not.
#
JENKINS_ENABLE_ACCESS_LOG="no"
## Type: integer
## Default: 100
## ServiceRestart: jenkins
#
# Maximum number of HTTP worker threads.
#
JENKINS_HANDLER_MAX="100"
## Type: integer
## Default: 20
## ServiceRestart: jenkins
#
# Maximum number of idle HTTP worker threads.
#
JENKINS_HANDLER_IDLE="20"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Pass arbitrary arguments to Jenkins.
# Full option list: java -jar jenkins.war --help
#
JENKINS_ARGS=""
六、/var/lib/jenkins/:默认的JENKINS_HOME。目录结构如下:
-rw-r--r--. 1 jenkins jenkins 159 May 26 20:54 hudson.model.UpdateCenter.xml
-rw-------. 1 jenkins jenkins 1680 May 26 20:54 identity.key.enc
drwxr-xr-x. 2 jenkins jenkins 4096 May 26 20:53 jobs
drwxr-xr-x. 3 jenkins jenkins 4096 May 26 20:54 logs
-rw-r--r--. 1 jenkins jenkins 907 May 26 20:54 nodeMonitors.xml
drwxr-xr-x. 2 jenkins jenkins 4096 May 26 20:54 nodes
drwxr-xr-x. 21 jenkins jenkins 4096 May 26 20:54 plugins
-rw-r--r--. 1 jenkins jenkins 64 May 26 20:53 secret.key
-rw-r--r--. 1 jenkins jenkins 0 May 26 20:53 secret.key.not-so-secret
drwx------. 4 jenkins jenkins 4096 May 26 20:54 secrets
drwxr-xr-x. 2 jenkins jenkins 4096 May 26 20:54 updates
drwxr-xr-x. 2 jenkins jenkins 4096 May 26 20:54 userContent
七、Jenkins日志文件 /var/log/jenkins/jenkins.log