LoginSignup
1
1

More than 1 year has passed since last update.

gitにコミットしたらJenkinsのジョブが起動するようにする

Posted at

やりたいこと

gitにコミットしたらJenkinsのジョブが起動するようにしたい。

手順

諸々コンテナを準備

JenkinsでAPIトークンを発行

ユーザアイコン → 設定 → APIトークン

Jenkinsでリモートトリガーを設定

ジョブ → 設定 → リモートトリガー → 認証トークン

gitリポジトリのupdateフックを設定

xxx.git/hook/update
#!/bin/sh

refname="$1"
oldrev="$2"
newrev="$3"

case "$refname" in
	refs/heads/master)
                curl -X POST --user "認証ID:APIトークン" http://picobuildcont01:8080/job/pico-playground-master/build?TOKEN=認証トークン
                echo "Invoke jenkins job completed: pico-playground-master"
		;;
	*)
		echo "No commit action"
		exit 0 
		;;
esac

exit 0
1
1
0

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
1
1