表題の通りです。とても初歩的な質問
になってしまいますが、質問させてください。
###環境
- バージョン管理システム
GitHub
- チケット管理システム
BackLog
- そのほかツール
Webhook
###実現したいこと
下記サイトを参考にして、タイトルに記載してあることを実現したいと思っています。
ただ大変初歩的ではあるのですが、サイト下段に記載されているRubyのプログラムをどこに実装すればいいのかもわかっていない状態です。
ruby
1def parse_json(json) 2 event = JSON.parse(json, :object_class => HookBaseObject) 3 event.extend(PushEvent) 4 event.repository.extend(Repository) 5 if event.commits 6 event.commits.each { |commit| commit.extend(Commit) } 7 end 8 event 9 end 10 11 def git_push_to_backlog(event) 12 description = event.repository.description 13 return unless description 14 15 # ex. [master]xxx@xxx.git.backlog.jp:/SANDBOX/sandbox.git 16 matches = description.scan /(?:\[(\S+)\])?(\S+?@\S*git.backlog.jp:\S+\.git)/ 17 18 Dir.chdir(event.repository.local_path) do 19 begin 20 matches.each do |branch, url| 21 if branch 22 system('git', 'push', '-f', url, branch) 23 else 24 system('git', 'push', '-f', '--mirror', url) 25 end 26 end 27 rescue => error 28 log_error(error) 29 end 30 end 31 end 32 33 def build_comment(commit, event, signature) 34 comment = '' 35 branch_name = event.ref_name 36 branch_url = event.repository.branch_page_url(branch_name) 37 comment << "**Author:** #{commit.author.name}\n" 38 comment << "**Branch:** [#{branch_name}](#{branch_url})\n" 39 comment << "**Commit:** [#{commit.id[0,7]}](#{commit.url})\n" 40 comment << "\n" 41 comment << commit.message.gsub(/^/, '>') + "\n" 42 comment << "\n" 43 comment << signature 44 end
人に質問するレベルのことではないことは重々承知していますが、Webhookの実装先など具体的に
表現されているサイトなどありましたら、教えていただけたら嬉しいです。
あなたの回答
tips
プレビュー