githubにpushされたら自動でビルドする

1. Settings > Service hooks > Jenkins(git plugin)

2. Jenkins Urlを設定
http://{JenkinsのURL}/git/notifyCommit?url={gitリポジトリのURL}

例:http://example.jenkins/git/notifyCommit?url=git@github.com:example/example.git

  • Jenkins側の設定

1. 設定 > ビルド・トリガ > SCMをポーリング
チェックを入れ、スケジュールを設定する

  • 確認

githubの設定でActiveにチェックを入れ、pushした時にJenkinsの「Gitのポーリングログ」が動いていることを確認

[Python]Python2.6→2.7へアップデートするにあたってやったこと

Jubatusを動かすにはPython2.7以上が必要.検証環境が2.6だった為アップデートを行った.
http://wasure-memo.h-tsk.com/2012/03/centos-62-python-272.html

1.インストールに必要なものをインストール

$ sudo yum install zlib zlib-devel tk-devel tcl-devel sqlite-devel ncurses-devel gdbm-devel readline-devel bzip2-devel db4-devel openssl-devel

2.Pythonをダウンロードして解凍する

$ wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
$ tar zxvf Python-2.7.2.tgz

3.インストール

$ cd Python-2.7.2
$ ./configure --with-threads --enable-shared

4.エラー対策(x86_64の場合)ここで,実行すると
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
とエラーで動かない.コンパイルはされているので,シンボリックを貼る

$ ln -s /usr/local/lib/libpython2.7.so.1.0 /lib64/

@CentOS

  • Python2.7のinstall
http://wasure-memo.h-tsk.com/2012/03/centos-62-python-272.html
http://memo.yomukaku.net/entries/jbRkQkq

wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgztar zxvf Python-2.7.2.tgz
sudo yum install zlib zlib-devel tk-devel tcl-devel sqlite-devel ncurses-devel gdbm-devel readline-devel bzip2-devel db4-devel openssl-devel
cd Python-2.7.2
./configure --with-threads --enable-shared
make
sudo make install
python2.7
  • pipのinstall
wget http://peak.telecommunity.com/dist/ez_setup.py
sudo /usr/local/bin/easy_install-2.7 pip

$ sudo /usr/local/bin/pip-2.7 install jubatus

$ sudo /usr/local/bin/pip-2.7 install MySQL-python

※エラー1:ここでmysql_configがないって怒られた

$ sudo yum install MySQL-devel.x86_64
$ which mysql_config

※エラー2:インストールできない
無理矢理だけど

$ sudo cp -rp /usr/lib64/python2.6/site-packages/_mysql* /usr/local/lib/python2.7/site-packages
$ sudo cp -rp /usr/lib64/python2.6/site-packages/MySQL* /usr/local/lib/python2.7/site-packages

一応できた…


ちなみにエラー2のエラーログは

$ sudo /usr/local/bin/pip install MySQL-python
Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
   
Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python
    building '_mysql' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
    _mysql.c:44 から include されたファイル中:
    /usr/include/mysql/my_config.h:422:1: 警告: "HAVE_WCSCOLL" が再定義されました
    /usr/local/include/python2.7/Python.h:8 から include されたファイル中,
                     _mysql.c:29 から:
    /usr/local/include/python2.7/pyconfig.h:887:1: 警告: ここが以前の宣言がある位置です
    gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64 -L/usr/local/lib -lmysqlclient_r -lpthread -lm -lrt -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so
    /usr/bin/ld: cannot find -lmysqlclient_r
    collect2: ld はステータス 1 で終了しました
    error: command 'gcc' failed with exit status 1
    Complete output from command /usr/local/bin/python2.7 -c "import setuptools;__file__='/tmp/pip-build-root/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Q9RYLv-record/install-record.txt --single-version-externally-managed:
    running install

running build

running build_py

copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7

copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb

copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants

running build_ext

building '_mysql' extension

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1

_mysql.c:44 から include されたファイル中:

/usr/include/mysql/my_config.h:422:1: 警告: "HAVE_WCSCOLL" が再定義されました

/usr/local/include/python2.7/Python.h:8 から include されたファイル中,

                 _mysql.c:29 から:

/usr/local/include/python2.7/pyconfig.h:887:1: 警告: ここが以前の宣言がある位置です

gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64 -L/usr/local/lib -lmysqlclient_r -lpthread -lm -lrt -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so

/usr/bin/ld: cannot find -lmysqlclient_r

collect2: ld はステータス 1 で終了しました

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/local/bin/python2.7 -c "import setuptools;__file__='/tmp/pip-build-root/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Q9RYLv-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-root/MySQL-python

Jenkinsサーバを移行する

Jenkinsサーバを移行するにあたり、jobをどうやって持っていけばいいのかわからなかったので調べてみた。

結果、jobをコピーすればいいだけらしい。簡単!
JENKINS_HOMEの下のjobsディレクトリをまるっとコピー(もちろん権限も引き継いで)して再起動すればおk。

てのは
Export/import jobs in Jenkins - Stack Overflow
とか
Administering Jenkins - Jenkins - Jenkins Wiki
に書いてありました。

HTTPヘッダとコンポーネントのキャッシュについて整理

画像などの静的ファイルのキャッシュとHTTPヘッダの関係について最近の調査結果をメモメモ。

Expiresヘッダ

Expires:Mon, 27 Aug 2012 04:44:15 GMT

レスポンスのボディがキャッシュとして新鮮でなくなる日時。絶対時間で表記。
この日時まではブラウザにファイル自体がキャッシュされるため、無駄なHTTP通信を避けることができる。
If-Modified-Sinceリクエストヘッダを利用することで、提示した日時以降にリソースが更新されていたらリソースを取得する。

 If-Modified-Since: Sat, 29 Oct 2012 19:43:31 GMT

この条件付きGETでリクエストすると、
「指定された時刻以降にリソースが更新されていなければ、304を返し、レスポンスにボディを含めない。」ようにサーバは振る舞う。

Cache-controlヘッダ

クライアントーサーバでのキャッシュ方法を示す。no-cache(キャッシュしない)やmax-age(どれぐらいの期間キャッシュするか)を指定。

Cache-Control:max-age=604800

こちらは相対時間(秒)で表記。これは1週間キャッシュするの意味。


IPA ISEC セキュア・プログラミング講座:Webアプリケーション編 第5章 暴露対策:プロキシキャッシュ対策

Webを支える技術 -HTTP、URI、HTML、そしてREST (WEB+DB PRESS plus)

Webを支える技術 -HTTP、URI、HTML、そしてREST (WEB+DB PRESS plus)

リモートプロジェクトをworkspaceに取り込む方法

2パターンある。EGitプラグインが入っている前提で。

■コマンドでgit cloneした後にworkspaceに取り込む

  1. $ git clone ***@***.git
  2. $ mvn eclipse:eclipse <eclipseからプロジェクトとして認識させる
  3. Eclipseで「Import>Existing Projects into Workspace>Select root directory」
  4. 「Team>Share Project>Git」で同期

Eclipseから取り込む

  1. Import>Git>Projects from Git>URI
  2. LocationのURIの欄に「***@***.git」を入力
  3. ConnectionのProtocolの欄で「ssh」を選択
  4. ひたすらNext
  5. 「Select a wizard to use for importing projects」で「Import existing projects」を選択
  6. ターミナルから「$mvn eclipse:eclipse」を実行
  7. Eclipseに戻りNext、Finish


ちなみにmvn eclipse:eclipseをやる理由は.projectなどのファイルがリモートプロジェクトに存在してないからであって、そもそも存在している場合はやる必要はない。