RHEL6.6にJenkinsをインストール

環境

  • RHEL 6.6 基本サーバーでインストール
  • CPU 4
  • Mem 6GB

IPはインストール中に設定。

iptablesselinuxは無効にすること

iptables無効化

# service iptables stop
# chkconfig iptables off

selinux無効化

# vi /etc/selinux/config
enforcing -> disabled

構築手順

CentOSリポジトリ追加

# vi /etc/yum.repos.d/CentOS.repo

[base]
name=CentOS-6.1 - Base
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-6.1 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-6.1 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

パッケージ導入

# yum update
# yum install java-1.7.0-openjdk
# jenkinsリポジトリ追加
# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
# rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
# yum install httpd jenkins

jenkins設定ファイルを以下のように編集する

[root@jerry ~]# diff -u /etc/sysconfig/jenkins jenkins
--- /etc/sysconfig/jenkins      2015-09-07 16:01:20.000000000 +0900
+++ jenkins     2015-09-09 19:42:44.048979191 +0900
@@ -44,7 +44,9 @@
 #
 # Options to pass to java when running Jenkins.
 #
-JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
+#JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
+JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.util.ProcessTree.disable=true"
+

 ## Type:        integer(0:65535)
 ## Default:     8080
@@ -53,7 +55,8 @@
 # Port Jenkins is listening on.
 # Set to -1 to disable
 #
-JENKINS_PORT="8080"
+#JENKINS_PORT="8008"
+JENKINS_PORT="-1"

 ## Type:        string
 ## Default:     ""
@@ -107,7 +110,7 @@
 # Ajp13 Port Jenkins is listening on.
 # Set to -1 to disable
 #
-JENKINS_AJP_PORT="8009"
+JENKINS_AJP_PORT="8109"

 ## Type:        string
 ## Default:     ""
@@ -158,4 +161,5 @@
 # Pass arbitrary arguments to Jenkins.
 # Full option list: java -jar jenkins.war --help
 #
-JENKINS_ARGS=""
+#JENKINS_ARGS=""
+JENKINS_ARGS="--prefix=/jenkins"

httpdの設定ファイルを以下のように編集

# vi /etc/httpd/conf.d/jenkins.conf

ProxyPass           /jenkins ajp://localhost:8109/jenkins nocanon
ProxyPassReverse    /jenkins ajp://localhost:8109/jenkins
ProxyRequests       Off
AllowEncodedSlashes On
<Proxy "ajp://localhost:8109/jenkins">
  Order deny,allow
  Allow from all
</Proxy>

サービス起動

# /etc/init.d/httpd start
# /etc/init.d/jenkins start
# chkconfig jenkins on
# chkconfig httpd on

ブラウザでhttp://[IP address]/jenkinsでアクセスできる。

proxy設定

Jenkinsトップ -> Jenkinsの管理 -> プラグインの管理 -> 高度な設定

key value
サーバー proxy server
ポート番号 port number
ユーザー名 hogehoge
パスワード hogehoge

参考URL http://ymasuda.com/blog/install-jenkins-to-linux/