■ドキュメント
■インストール要件
■インストール
・Linuxインストール
・LTSのインストール方法
[centos7copy]$ wget -O /etc/yum.repos.d/jenkins.repo \
> https://pkg.jenkins.io/redhat-stable/jenkins.repo
[centos7copy]$ ll /etc/yum.repos.d/jenkins.repo
-rw-r--r--. 1 root root 85 Nov 30 2016 /etc/yum.repos.d/jenkins.repo
[centos7copy]$ cat /etc/yum.repos.d/jenkins.repo
[jenkins]
name=Jenkins-stable
baseurl=http://pkg.jenkins.io/redhat-stable
gpgcheck=1 ←これを一時的に0にしてgpgcheckをチャラく飛ばす
[centos7copy]$ yum install -y jenkins
----(略)----
Installed:
jenkins.noarch 0:2.249.3-1.1
Complete!
・インストールされたファイル
[centos7copy]$ rpm -ql jenkins
/etc/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/usr/lib/jenkins/jenkins.war
/usr/sbin/rcjenkins
/var/cache/jenkins
/var/lib/jenkins
/var/log/jenkins
・起動スクリプト
[centos7copy]$ cat -n /etc/init.d/jenkins
1 #!/bin/sh
2 #
3 # RedHat system statup script for Jenkins
4 # Based on SUSE system statup script for Jenkins
5 # Copyright (C) 2007 Pascal Bleser
6 #
7 # This library is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or (at
10 # your option) any later version.
11 #
12 # This library is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
20 # USA.
21 #
22 ###############################################################################
23 #
24 # chkconfig: 35 99 01
25 # description: Jenkins Automation Server
26 #
27 ###############################################################################
28 ### BEGIN INIT INFO
29 # Provides: jenkins
30 # Required-Start: $local_fs $remote_fs $network $time $named
31 # Should-Start: $time sendmail
32 # Required-Stop: $local_fs $remote_fs $network $time $named
33 # Should-Stop: $time sendmail
34 # Default-Start: 3 5
35 # Default-Stop: 0 1 2 6
36 # Short-Description: Jenkins Automation Server
37 # Description: Jenkins Automation Server
38 ### END INIT INFO
39
40 # Check for missing binaries (stale symlinks should not happen)
41 JENKINS_WAR="/usr/lib/jenkins/jenkins.war"
42 test -r "$JENKINS_WAR" || { echo "$JENKINS_WAR not installed";
43 if [ "$1" = "stop" ]; then exit 0;
44 else exit 5; fi; }
45
46 # Check for existence of needed config file and read it
47 JENKINS_CONFIG=/etc/sysconfig/jenkins
48 test -e "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not existing";
49 if [ "$1" = "stop" ]; then exit 0;
50 else exit 6; fi; }
51 test -r "$JENKINS_CONFIG" || { echo "$JENKINS_CONFIG not readable. Perhaps you forgot 'sudo'?";
52 if [ "$1" = "stop" ]; then exit 0;
53 else exit 6; fi; }
54
55 JENKINS_PID_FILE="/var/run/jenkins.pid"
56 JENKINS_LOCKFILE="/var/lock/subsys/jenkins"
57
58 # Source function library.
59 . /etc/init.d/functions
60
61 # Read config
62 [ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG"
63
64 # Set up environment accordingly to the configuration settings
65 [ -n "$JENKINS_HOME" ] || { echo "JENKINS_HOME not configured in $JENKINS_CONFIG";
66 if [ "$1" = "stop" ]; then exit 0;
67 else exit 6; fi; }
68 [ -d "$JENKINS_HOME" ] || { echo "JENKINS_HOME directory does not exist: $JENKINS_HOME";
69 if [ "$1" = "stop" ]; then exit 0;
70 else exit 1; fi; }
71
72 # Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
73 # see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
74 candidates="
75 /etc/alternatives/java
76 /usr/lib/jvm/java-1.8.0/bin/java
77 /usr/lib/jvm/jre-1.8.0/bin/java
78 /usr/lib/jvm/java-1.7.0/bin/java
79 /usr/lib/jvm/jre-1.7.0/bin/java
80 /usr/lib/jvm/java-11.0/bin/java
81 /usr/lib/jvm/jre-11.0/bin/java
82 /usr/lib/jvm/java-11-openjdk-amd64
83 /usr/bin/java
84 "
85 for candidate in $candidates
86 do
87 [ -x "$JENKINS_JAVA_CMD" ] && break
88 JENKINS_JAVA_CMD="$candidate"
89 done
90
91 JAVA_CMD="$JENKINS_JAVA_CMD $JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
92 PARAMS="--logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon"
93 [ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT"
94 [ -n "$JENKINS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpListenAddress=$JENKINS_LISTEN_ADDRESS"
95 [ -n "$JENKINS_HTTPS_PORT" ] && PARAMS="$PARAMS --httpsPort=$JENKINS_HTTPS_PORT"
96 [ -n "$JENKINS_HTTPS_KEYSTORE" ] && PARAMS="$PARAMS --httpsKeyStore=$JENKINS_HTTPS_KEYSTORE"
97 [ -n "$JENKINS_HTTPS_KEYSTORE_PASSWORD" ] && PARAMS="$PARAMS --httpsKeyStorePassword='$JENKINS_HTTPS_KEYSTORE_PASSWORD'"
98 [ -n "$JENKINS_HTTPS_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --httpsListenAddress=$JENKINS_HTTPS_LISTEN_ADDRESS"
99 [ -n "$JENKINS_HTTP2_PORT" ] && PARAMS="$PARAMS --http2Port=$JENKINS_HTTP2_PORT"
100 [ -n "$JENKINS_HTTP2_LISTEN_ADDRESS" ] && PARAMS="$PARAMS --http2ListenAddress=$JENKINS_HTTP2_LISTEN_ADDRESS"
101 [ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL"
102 [ -n "$JENKINS_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$JENKINS_HANDLER_STARTUP"
103 [ -n "$JENKINS_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$JENKINS_HANDLER_MAX"
104 [ -n "$JENKINS_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$JENKINS_HANDLER_IDLE"
105 [ -n "$JENKINS_EXTRA_LIB_FOLDER" ] && PARAMS="$PARAMS --extraLibFolder=$JENKINS_EXTRA_LIB_FOLDER"
106 [ -n "$JENKINS_ARGS" ] && PARAMS="$PARAMS $JENKINS_ARGS"
107
108 if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then
109 PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/jenkins/access_log"
110 fi
111
112 RETVAL=0
113
114 case "$1" in
115 start)
116 echo -n "Starting Jenkins "
117 daemon --user "$JENKINS_USER" --pidfile "$JENKINS_PID_FILE" $JAVA_CMD $PARAMS > /dev/null
118 RETVAL=$?
119 if [ $RETVAL = 0 ]; then
120 success
121 echo > "$JENKINS_PID_FILE" # just in case we fail to find it
122 MY_SESSION_ID=`/bin/ps h -o sess -p $$`
123 # get PID
124 /bin/ps hww -u "$JENKINS_USER" -o sess,ppid,pid,cmd | \
125 while read sess ppid pid cmd; do
126 [ "$ppid" = 1 ] || continue
127 # this test doesn't work because Jenkins sets a new Session ID
128 # [ "$sess" = "$MY_SESSION_ID" ] || continue
129 echo "$cmd" | grep $JENKINS_WAR > /dev/null
130 [ $? = 0 ] || continue
131 # found a PID
132 echo $pid > "$JENKINS_PID_FILE"
133 done
134 touch $JENKINS_LOCKFILE
135 else
136 failure
137 fi
138 echo
139 ;;
140 stop)
141 echo -n "Shutting down Jenkins "
142 killproc jenkins
143 rm -f $JENKINS_LOCKFILE
144 RETVAL=$?
145 echo
146 ;;
147 try-restart|condrestart)
148 if test "$1" = "condrestart"; then
149 echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
150 fi
151 $0 status
152 if test $? = 0; then
153 $0 restart
154 else
155 : # Not running is not a failure.
156 fi
157 ;;
158 restart)
159 $0 stop
160 $0 start
161 ;;
162 force-reload)
163 echo -n "Reload service Jenkins "
164 $0 try-restart
165 ;;
166 reload)
167 $0 restart
168 ;;
169 status)
170 status jenkins
171 RETVAL=$?
172 ;;
173 probe)
174 ## Optional: Probe for the necessity of a reload, print out the
175 ## argument to this init script which is required for a reload.
176 ## Note: probe is not (yet) part of LSB (as of 1.9)
177
178 test "$JENKINS_CONFIG" -nt "$JENKINS_PID_FILE" && echo reload
179 ;;
180 *)
181 echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
182 exit 1
183 ;;
184 esac
185 exit $RETVAL
・ログファイル
[起動前]
[centos7copy]$ ll /var/log/jenkins/
total 0
[起動後]
[centos7copy]$ service jenkins start
Starting jenkins (via systemctl): [ OK ]
[centos7copy]$ ll /var/log/jenkins/
total 8
-rw-r--r--. 1 jenkins jenkins 5750 Nov 12 09:54 jenkins.log
[centos7copy]$ wc -l /var/log/jenkins/jenkins.log
55 /var/log/jenkins/jenkins.log
[centos7copy]$ head /var/log/jenkins/jenkins.log
Running from: /usr/lib/jenkins/jenkins.war
2020-11-12 00:54:09.344+0000 [id=1] WARNING winstone.Logger#logInternal: Parameter handlerCountMax is now deprecated
2020-11-12 00:54:09.358+0000 [id=1] WARNING winstone.Logger#logInternal: Parameter handlerCountMaxIdle is now deprecated
2020-11-12 00:54:09.368+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @392ms to org.eclipse.jetty.util.log.JavaUtilLog
2020-11-12 00:54:09.412+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2020-11-12 00:54:11.607+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2020-11-12 00:54:11.649+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.30.v20200611; built: 2020-06-11T12:34:51.929Z; git: 271836e4c1f4612f12b7bb13ef5a92a927634b0d; jvm 1.8.0_262-b10
2020-11-12 00:54:11.953+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-11-12 00:54:11.985+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2020-11-12 00:54:11.986+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
[centos7copy]$ tail /var/log/jenkins/jenkins.log
*************************************************************
*************************************************************
*************************************************************
2020-11-12 00:54:36.215+0000 [id=47] INFO h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2020-11-12 00:54:36.218+0000 [id=47] INFO hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1
2020-11-12 00:54:36.220+0000 [id=47] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 11,586 ms
2020-11-12 00:54:36.800+0000 [id=29] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
2020-11-12 00:54:36.811+0000 [id=21] INFO hudson.WebAppMain$3#run: Jenkins is fully up and running
・ログローテーション設定
[centos7copy]$ cat /etc/logrotate.d/jenkins
/var/log/jenkins/jenkins.log /var/log/jenkins/access_log {
compress
dateext
maxage 365
rotate 99
size=+4096k
notifempty
missingok
create 644
copytruncate
}
・プロセス確認
[centos7copy]$ ps -ef | grep jenkin[s]
jenkins 36635 1 16 09:54 ? 00:00:24 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
[centos7copy]$ pstree -p 36635
[centos7copy]$ netstat -naptl | grep 36635
tcp6 0 0 :::8080 :::* LISTEN 36635/java
・ブラウザからアクセス
administratorの初期パスワードは、上記の通り
[centos7copy]$ cat /var/lib/jenkins/secrets/initialAdminPassword
9fc18b7d2bcf4b4997bb71c54912669a
上記のパスあーどを入力ると下記の画面に遷移する
上記の「Install suggested plugins」をクリック
※マニュアルによると、「to install the recommended set of plugins, which are based on most common use cases.」とのこと。
→インストールが始まる。
上記セットアップが完了すると下記のようにadministratorパスワード変更画面に遷移する
パスワード変更すると下記のような画面に遷移する。
左ペイン内の「新規ジョブ作成」をクリック
いったん戻って「開発者」をクリック
戻って「jenkinsの管理」をクリック
もう一回ログを見てみる。
[centos7copy]$ ls -l /var/log/jenkins/
total 52
-rw-r--r--. 1 jenkins jenkins 48348 Nov 12 10:15 jenkins.log
[centos7copy]$ wc -l /var/log/jenkins/jenkins.log
372 /var/log/jenkins/jenkins.log
・コンフィグ確認
[centos7copy]$ cat -n /etc/sysconfig/jenkins
1 ## Path: Development/Jenkins
2 ## Description: Jenkins Automation Server
3 ## Type: string
4 ## Default: "/var/lib/jenkins"
5 ## ServiceRestart: jenkins
6 #
7 # Directory where Jenkins store its configuration and working
8 # files (checkouts, build reports, artifacts, ...).
9 #
10 JENKINS_HOME="/var/lib/jenkins"
11
12 ## Type: string
13 ## Default: ""
14 ## ServiceRestart: jenkins
15 #
16 # Java executable to run Jenkins
17 # When left empty, we'll try to find the suitable Java.
18 #
19 JENKINS_JAVA_CMD=""
20
21 ## Type: string
22 ## Default: "jenkins"
23 ## ServiceRestart: jenkins
24 #
25 # Unix user account that runs the Jenkins daemon
26 # Be careful when you change this, as you need to update
27 # permissions of $JENKINS_HOME and /var/log/jenkins.
28 #
29 JENKINS_USER="jenkins"
30
31 ## Type: string
32 ## Default: "false"
33 ## ServiceRestart: jenkins
34 #
35 # Whether to skip potentially long-running chown at the
36 # $JENKINS_HOME location. Do not enable this, "true", unless
37 # you know what you're doing. See JENKINS-23273.
38 #
39 #JENKINS_INSTALL_SKIP_CHOWN="false"
40
41 ## Type: string
42 ## Default: "-Djava.awt.headless=true"
43 ## ServiceRestart: jenkins
44 #
45 # Options to pass to java when running Jenkins.
46 #
47 JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
48
49 ## Type: integer(0:65535)
50 ## Default: 8080
51 ## ServiceRestart: jenkins
52 #
53 # Port Jenkins is listening on.
54 # Set to -1 to disable
55 #
56 JENKINS_PORT="8080"
57
58 ## Type: string
59 ## Default: ""
60 ## ServiceRestart: jenkins
61 #
62 # IP address Jenkins listens on for HTTP requests.
63 # Default is all interfaces (0.0.0.0).
64 #
65 JENKINS_LISTEN_ADDRESS=""
66
67 ## Type: integer(0:65535)
68 ## Default: ""
69 ## ServiceRestart: jenkins
70 #
71 # HTTPS port Jenkins is listening on.
72 # Default is disabled.
73 #
74 JENKINS_HTTPS_PORT=""
75
76 ## Type: string
77 ## Default: ""
78 ## ServiceRestart: jenkins
79 #
80 # Path to the keystore in JKS format (as created by the JDK 'keytool').
81 # Default is disabled.
82 #
83 JENKINS_HTTPS_KEYSTORE=""
84
85 ## Type: string
86 ## Default: ""
87 ## ServiceRestart: jenkins
88 #
89 # Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE.
90 # Default is disabled.
91 #
92 JENKINS_HTTPS_KEYSTORE_PASSWORD=""
93
94 ## Type: string
95 ## Default: ""
96 ## ServiceRestart: jenkins
97 #
98 # IP address Jenkins listens on for HTTPS requests.
99 # Default is disabled.
100 #
101 JENKINS_HTTPS_LISTEN_ADDRESS=""
102
103 ## Type: integer(0:65535)
104 ## Default: ""
105 ## ServiceRestart: jenkins
106 #
107 # HTTP2 port Jenkins is listening on.
108 # Default is disabled.
109 #
110 # Notice: HTTP2 support may require additional configuration, see Winstone
111 # documentation for more information.
112 #
113 JENKINS_HTTP2_PORT=""
114
115 ## Type: string
116 ## Default: ""
117 ## ServiceRestart: jenkins
118 #
119 # IP address Jenkins listens on for HTTP2 requests.
120 # Default is disabled.
121 #
122 # Notice: HTTP2 support may require additional configuration, see Winstone
123 # documentation for more information.
124 #
125 JENKINS_HTTP2_LISTEN_ADDRESS=""
126
127 ## Type: integer(1:9)
128 ## Default: 5
129 ## ServiceRestart: jenkins
130 #
131 # Debug level for logs -- the higher the value, the more verbose.
132 # 5 is INFO.
133 #
134 JENKINS_DEBUG_LEVEL="5"
135
136 ## Type: yesno
137 ## Default: no
138 ## ServiceRestart: jenkins
139 #
140 # Whether to enable access logging or not.
141 #
142 JENKINS_ENABLE_ACCESS_LOG="no"
143
144 ## Type: integer
145 ## Default: 100
146 ## ServiceRestart: jenkins
147 #
148 # Maximum number of HTTP worker threads.
149 #
150 JENKINS_HANDLER_MAX="100"
151
152 ## Type: integer
153 ## Default: 20
154 ## ServiceRestart: jenkins
155 #
156 # Maximum number of idle HTTP worker threads.
157 #
158 JENKINS_HANDLER_IDLE="20"
159
160 ## Type: string
161 ## Default: ""
162 ## ServiceRestart: jenkins
163 #
164 # Folder for additional jar files to add to the Jetty class loader.
165 # See Winstone documentation for more information.
166 # Default is disabled.
167 #
168 JENKINS_EXTRA_LIB_FOLDER=""
169
170 ## Type: string
171 ## Default: ""
172 ## ServiceRestart: jenkins
173 #
174 # Pass arbitrary arguments to Jenkins.
175 # Full option list: java -jar jenkins.war --help
176 #
177 JENKINS_ARGS=""

















