LoginSignup
33

More than 5 years have passed since last update.

git push で jenkins ビルドする

Last updated at Posted at 2013-06-13

jenkins の設定

Jenkinsのプロジェクトの設定で、ビルド・トリガ>リモートからビルド を選択し、ビルド用のトークンを設定する。
ここでは仮に"hogehoge"としたとする。

ためしにURLを叩いてみる

$ curl http://localhost:8080/job/git-test/build?token=hogehoge

これでビルドが実行されればOK

ちなみに、トークンを使用するのは「セキュリティを有効」に設定している場合のみ。

まちがってユーザ設定しないまま、セキュリティを有効にして管理画面を閉じてしまうと何もできなくなってしまう(復帰方法はるのかな?)ので注意。

その場合、以下のページを参考に「セキュリティを有効にする」を無効化することができた。

git リポジトリのフックスクリプトに追加する

※サーバ側のリポジトリで設定する

hook/post-update ファイルを用意

#!/bin/sh

curl -s http://localhost:8080/job/git-test/build?token=hogehoge
echo "jenkins build run."

実行権限を与えるのを忘れずに

$ chmod +x post-update

試しにpushしてみる

試しに該当リポジトリをローカルで修正・コミット、リポジトリサーバへpush してみて、jenkinsのビルドが実行されればOK

$ git push
Counting objects: 5, done.
Writing objects: 100% (3/3), 281 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: jenkins build run.
To git@vagrant:testing
   4f72d57..805e344  master -> master

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33