blog/content/post/2012/07/29/2012-07-29-00001564.md

157 lines
15 KiB
Markdown
Raw Normal View History

2019-03-31 11:00:21 +00:00
---
title: Ubuntu 12.04 に jenkins をインストールする
author: kazu634
date: 2012-07-29
wordtwit_post_info:
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:5465;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
categories:
- jenkins
- ubuntu
---
<div class="section">
<p>
<a href="http://build-shokunin.org/juc2012/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://build-shokunin.org/juc2012/', ' &#187; Jenkins ユーザ・カンファレンス 2012 東京 日本Jenkinsユーザ会');" target="_blank"> &#187; Jenkins ユーザ・カンファレンス 2012 東京 日本Jenkinsユーザ会</a>に参加してきました。
</p>
<p>
参加した目的としては
</p>
<ol>
<li>
CIツールの目的を知りたい
</li>
<li>
jenkins で何ができるのかを知りたい
</li>
<li>
どのようなことを運用するときに気をつけるべきなのか知りたい
</li>
<li>
CIツールとしてではない jenkins の使い方を知りたい
</li>
</ol>
<p>
などといった目的で参加しました。いろいろな発表を聞いて、CIツールの概要・目的、jenkinsの使われ方が理解できたと思います。
</p>
<p>
そこでさっそく家の VM に jenkins をインストールしてみました。
</p>
<h4>
参考にしたサイト
</h4>
<ul>
<li>
<a href="http://pkg.jenkins-ci.org/debian/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://pkg.jenkins-ci.org/debian/', 'Debian Repository for Jenkins');" target="_blank">Debian Repository for Jenkins</a>
</li>
<li>
<a href="https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu" onclick="__gaTracker('send', 'event', 'outbound-article', 'https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu', 'https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu');" target="_blank">https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu</a>
</li>
</ul>
<h4>
インストールログ
</h4>
<p>
Ubuntu 12.04に jenkins をインストールしました。構成としてはフロントエンドに nginx を使用し、バックエンドの 8080 ポートに jenkins をインストールします:
</p>
<h5>
jenkinsのインストール
</h5>
<pre class="syntax-highlight">
$ wget <span class="synSpecial">-q</span> <span class="synSpecial">-O</span> - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key <span class="synStatement">|</span> sudo apt-key add -
<span class="synStatement">[</span>sudo<span class="synStatement">]</span> password <span class="synStatement">for</span> kazu634:
OK
$ sudo sh <span class="synStatement">-c</span> <span class="synStatement">'</span><span class="synConstant">echo deb http://pkg.jenkins-ci.org/debian binary/ &#62; /etc/apt/sources.list.d/jenkins.list</span><span class="synStatement">'</span>
$ ll /etc/apt/sources.list.d/
total <span class="synConstant">12</span>
drwxr-xr<span class="synStatement">-x</span> <span class="synConstant">2</span> root root <span class="synConstant">4096</span> <span class="synConstant">7</span><span class="synConstant">29</span> <span class="synConstant">22</span>:<span class="synConstant">38</span> ./
drwxr-xr<span class="synStatement">-x</span> <span class="synConstant">6</span> root root <span class="synConstant">4096</span> <span class="synConstant">7</span><span class="synConstant">29</span> <span class="synConstant">22</span>:<span class="synConstant">37</span> ../
-rw<span class="synStatement">-r</span>-<span class="synStatement">-r</span>-- <span class="synConstant">1</span> root root <span class="synConstant">45</span> <span class="synConstant">7</span><span class="synConstant">29</span> <span class="synConstant">22</span>:<span class="synConstant">38</span> jenkins.list
$ sudo aptitude update
<span class="synStatement">[</span>...<span class="synStatement">]</span>
$ sudo aptitude <span class="synStatement">install</span> jenkins
The following NEW packages will be installed:
ca-certificates-java<span class="synSpecial">{</span>a<span class="synSpecial">}</span> <span class="synStatement">daemon</span><span class="synSpecial">{</span>a<span class="synSpecial">}</span> fontconfig<span class="synSpecial">{</span>a<span class="synSpecial">}</span> fontconfig-config<span class="synSpecial">{</span>a<span class="synSpecial">}</span> hicolor-icon-theme<span class="synSpecial">{</span>a<span class="synSpecial">}</span> icedtea<span class="synConstant">-6</span>-jre-cacao<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
icedtea<span class="synConstant">-6</span>-jre-jamvm<span class="synSpecial">{</span>a<span class="synSpecial">}</span> icedtea-netx<span class="synSpecial">{</span>a<span class="synSpecial">}</span> icedtea-netx-common<span class="synSpecial">{</span>a<span class="synSpecial">}</span> java-common<span class="synSpecial">{</span>a<span class="synSpecial">}</span> jenkins libasound2<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libasyncns0<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libatk-wrapper-java<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libatk-wrapper-java-jni<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libatk1.<span class="synConstant">0-0</span><span class="synSpecial">{</span>a<span class="synSpecial">}</span> libatk1.<span class="synConstant"></span>-data<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libavahi-client3<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libavahi-common-data<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libavahi-common3<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libcairo2<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libcups2<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libdatrie1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libflac8<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libfontconfig1<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libgdk-pixbuf2.<span class="synConstant">0-0</span><span class="synSpecial">{</span>a<span class="synSpecial">}</span> libgdk-pixbuf2.<span class="synConstant"></span>-common<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libgif4<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libgtk2.<span class="synConstant">0-0</span><span class="synSpecial">{</span>a<span class="synSpecial">}</span> libgtk2.<span class="synConstant"></span>-bin<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libgtk2.<span class="synConstant"></span>-common<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libjasper1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libjpeg-turbo8<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libjpeg8<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libjson0<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libnspr4<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libnss3<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libnss3-1d<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libogg0<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libpango1.<span class="synConstant">0-0</span><span class="synSpecial">{</span>a<span class="synSpecial">}</span> libpcsclite1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libpixman<span class="synConstant">-1-0</span><span class="synSpecial">{</span>a<span class="synSpecial">}</span> libpulse0<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libsndfile1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libthai-data<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libthai0<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libtiff4<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libvorbis0a<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libvorbisenc2<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxcb-render0<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxcb-shm0<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxcomposite1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxcursor1<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
libxdamage1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxfixes3<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxft2<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxi6<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxinerama1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxrandr2<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxrender1<span class="synSpecial">{</span>a<span class="synSpecial">}</span> libxtst6<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
openjdk<span class="synConstant">-6</span>-jre<span class="synSpecial">{</span>a<span class="synSpecial">}</span> openjdk<span class="synConstant">-6</span>-jre-headless<span class="synSpecial">{</span>a<span class="synSpecial">}</span> openjdk<span class="synConstant">-6</span>-jre-lib<span class="synSpecial">{</span>a<span class="synSpecial">}</span> shared-mime-info<span class="synSpecial">{</span>a<span class="synSpecial">}</span> ttf-dejavu-core<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
ttf-dejavu-extra<span class="synSpecial">{</span>a<span class="synSpecial">}</span> tzdata-java<span class="synSpecial">{</span>a<span class="synSpecial">}</span> x11-common<span class="synSpecial">{</span>a<span class="synSpecial">}</span>
<span class="synConstant"></span> packages upgraded, <span class="synConstant">69</span> newly installed, <span class="synConstant"></span> to remove and <span class="synConstant"></span> not upgraded.
Need to get <span class="synConstant">96</span>.<span class="synConstant">1</span> MB of archives. After unpacking <span class="synConstant">181</span> MB will be used.
Do you want to <span class="synStatement">continue</span>? <span class="synStatement">[</span>Y/n/?<span class="synStatement">]</span> y
<span class="synStatement">[</span>...<span class="synStatement">]</span>
</pre>
<h5>
nginxのインストール
</h5>
<pre class="syntax-highlight">
$ sudo <span class="synSpecial">-s</span>
<span class="synComment"># nginx=stable</span>
<span class="synComment"># add-apt-repository ppa:nginx/$nginx</span>
The program <span class="synStatement">'</span><span class="synConstant">add-apt-repository</span><span class="synStatement">'</span> is currently not installed. You can <span class="synStatement">install</span> it by typing:
apt-get <span class="synStatement">install</span> python-software-properties
<span class="synComment"># echo &#34;deb http://ppa.launchpad.net/nginx/$nginx/ubuntu lucid main&#34; &#62; /etc/apt/sources.list.d/nginx-</span>
<span class="synPreProc">$nginx</span>-lucid.list
<span class="synComment"># apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C</span>
Executing: gpg <span class="synSpecial">--ignore-time-conflict</span> <span class="synSpecial">--no-options</span> <span class="synSpecial">--no-default-keyring</span> <span class="synSpecial">--secret-keyring</span> /tmp/tmp.UpyY1fEVhQ <span class="synSpecial">--trustdb-n</span>
ame /etc/apt/trustdb.gpg <span class="synSpecial">--keyring</span> /etc/apt/trusted.gpg <span class="synSpecial">--primary-keyring</span> /etc/apt/trusted.gpg <span class="synSpecial">--keyserver</span> keyserver.ubu
ntu.com <span class="synSpecial">--recv-keys</span> C300EE8C
gpg: requesting key C300EE8C from hkp server keyserver.ubuntu.com
gpg: key C300EE8C: public key <span class="synStatement">&#34;</span><span class="synConstant">Launchpad Stable</span><span class="synStatement">&#34;</span> imported
gpg: no ultimately trusted keys found
gpg: Total number processed: <span class="synConstant">1</span>
gpg: imported: <span class="synConstant">1</span> <span class="synStatement">(</span>RSA: <span class="synConstant">1</span><span class="synStatement">)</span>
<span class="synComment"># apt-get update</span>
<span class="synStatement">[</span>...<span class="synStatement">]</span>
<span class="synComment"># apt-get install nginx</span>
$ <span class="synStatement">cd</span> /etc/nginx/sites-available
$ sudo <span class="synStatement">rm</span> default
<span class="synStatement">[</span>sudo<span class="synStatement">]</span> password <span class="synStatement">for</span> kazu634:
$ sudo vi jenkins
$ cat jenkins
upstream app_server <span class="synSpecial">{</span>
server <span class="synConstant">127</span>.<span class="synConstant"></span>.<span class="synConstant"></span>.<span class="synConstant">1</span>:<span class="synConstant">8080</span> <span class="synIdentifier">fail_timeout</span>=<span class="synConstant"></span><span class="synStatement">;</span>
<span class="synSpecial">}</span>
server <span class="synSpecial">{</span>
listen <span class="synConstant">80</span><span class="synStatement">;</span>
server_name _<span class="synStatement">;</span>
location / <span class="synSpecial">{</span>
proxy_set_header X-Forwarded-For <span class="synPreProc">$proxy_add_x_forwarded_for</span><span class="synStatement">;</span>
proxy_set_header Host <span class="synPreProc">$http_host</span><span class="synStatement">;</span>
proxy_redirect off<span class="synStatement">;</span>
<span class="synStatement">if</span> <span class="synStatement">(!</span>-f <span class="synPreProc">$request_filename</span><span class="synStatement">)</span> <span class="synSpecial">{</span>
proxy_pass http://app_server<span class="synStatement">;</span>
<span class="synStatement">break;</span>
<span class="synSpecial">}</span>
}
}
$ sudo ln <span class="synStatement">-s</span> /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
$ sudo service nginx <span class="synStatement">restart</span>
</pre>
<h4>
アクセスしてみる
</h4>
<p>
<a href="http://f.hatena.ne.jp/sirocco634/20120729234752" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://f.hatena.ne.jp/sirocco634/20120729234752', '');" class="hatena-fotolife" target="_blank"><img src="http://cdn-ak.f.st-hatena.com/images/fotolife/s/sirocco634/20120729/20120729234752.jpg" alt="f:id:sirocco634:20120729234752j:image:w360" title="f:id:sirocco634:20120729234752j:image:w360" class="hatena-fotolife" width="360" /></a>
</p>
</div>