SlideShare a Scribd company logo
1 of 13
Download to read offline
Integrate Gitolite with Mantis
                   Jiahe Jou, 2012/08/31
Revisions
  DATE        Author              DESCRIPTION

2012/08/31   Jiahe Jou   Draft.
Outlines
● Main Idea of Synchronizing to Mantis

● Git Hooks Procedure

● Gitolite Common Hooks

● Intermediate Programs

● Send SMTP Mail
Main Idea of Synchronizing to Mantis


   User Git Push
                      Gitolite




                                     Post Hooks




                                 Intermediate Programs
      Mantis
Git Hooks Procedure
● The hooks procedure after git push:
    Receive Objects
                                             Post-commit Hook


                         Post-receive Hook
    Pre-receive Hook




                          Post-update Hook
       Update
      Repository
Gitolite Common Hooks
● /usr/share/gitolite/hooks/common/*
● post-receive:
   ...
   # read input objects
   while read oldrev newrev ref
   do
        # get the commit information
        subj=`git show -s --format="%s" $newrev`
        diff=`git show $newrev...$oldrev`
        msgs="$subj

   $diff"
         # excute pre-write perl script to sync mantis
         /home/gitolite/git2mantis.pl "$msgs"
         ...
   done
Gitolite Common Hooks
● Execute "gl-setup" to push common hooks to
  each repository
● Check whether hook scripts are pushed to
  each repositories
● Location: ~/repositories/*/hooks/*
Intermediate Programs
● /home/gitolite/git2mantis.pl
   #!/usr/bin/perl
   #
   # admin's ssh key must setup in 192.168.0.1
   # to log-in automatically.
   $host = "admin@192.168.0.1";

   $sshcmd = "/usr/bin/ssh ";
   $phpcmd = "/usr/bin/php";
   $checkincmd = "/var/www/mantis/scripts/git-checkin.php";

   $msg = $ARGV[0];

   # excute remote programs through ssh
   `$sshcmd $host $phpcmd $checkincmd <<< "$msg"`;
Intermediate Programs
● Mantis Server: 192.168.0.1:
  /var/www/mantis/scripts/git-checkin.php
   ...
   # Parsing the input to get issue number
   $t_commit_regexp = "/issueD*(d*)/";
   $t_line = readline("");
   iif (preg_match( $t_commit_regexp, $t_line, $t_matches ) == 0) {
          echo "Comment does not reference any issues.n";
          exit( 0 );
    }
   $t_issues[0] = $t_matches[1];
   ...
   # Call mantis helper function to insert issue note
   $t_issue_id = $t_issues[0];
   helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment,
   $t_history_old_value, $t_history_new_value, false );
Send SMTP Mail
● Modify ~/.gitolite/conf/gitolite.conf to add
  mailing list with "hooks.mailinglist"
   ...
   repo    testing
        config hooks.mailinglist = "alex.lin@innocomm.com, cc.
   chen@innocomm.com, cookie.liu@innocomm.com,
   ...
   jiahe.jou@innocomm.com, weili.luo@innocomm.com"
        RW+ = @all
        R         = daemon
        R         = gitweb
   ...
Send SMTP Mail
● Add the following to post-receive
   ...
   # get mailing list by git config
   recipients=`git config hooks.mailinglist`

   # execute pre-write script to send mail
   /home/gitolite/git2mail.py "$subj" "$diff" "$recipients"
   ...
Send SMTP Mail
● Send mail through SMTP with gmail
  #!/usr/bin/python
  import sys
  import smtplib

  subject = sys.argv[1]
  body = sys.argv[2]
  recipients = sys.argv[3]
  gmail_user = 'admin@gmail.com'
  gmail_pwd = 'password'

  smtpserver = smtplib.SMTP("smtp.gmail.com",587)
  smtpserver.ehlo()
  smtpserver.starttls()
  smtpserver.ehlo()
  smtpserver.login(gmail_user, gmail_pwd)

  header = 'To:' + recipients + 'n' + 'From: ' + gmail_user + 'n' + 'Subject:
  [Gitolite] ' + subject + ' n'
  msg = header + 'n' + body + 'nn'

  smtpserver.sendmail(gmail_user, recipients.split(', '), msg)
  smtpserver.close()
The End

More Related Content

What's hot

Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6
Maki Toshio
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
webelement
 
Open Social Data (Jaca), Alejandro Rivero
Open Social Data (Jaca), Alejandro RiveroOpen Social Data (Jaca), Alejandro Rivero
Open Social Data (Jaca), Alejandro Rivero
Aragón Open Data
 

What's hot (20)

Steam Learn: Composer
Steam Learn: ComposerSteam Learn: Composer
Steam Learn: Composer
 
Chef
ChefChef
Chef
 
Central Iowa Linux Users Group June 2020 Meeting Apache Guacamole
Central Iowa Linux Users Group June 2020 Meeting  Apache GuacamoleCentral Iowa Linux Users Group June 2020 Meeting  Apache Guacamole
Central Iowa Linux Users Group June 2020 Meeting Apache Guacamole
 
gunicorn introduction
gunicorn introductiongunicorn introduction
gunicorn introduction
 
Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platformBuilding serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platform
 
Git beyond basics
Git   beyond basicsGit   beyond basics
Git beyond basics
 
Analysing Github events with Neo4j
Analysing Github events with Neo4jAnalysing Github events with Neo4j
Analysing Github events with Neo4j
 
Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6Searched gems which supports only ruby 2.6
Searched gems which supports only ruby 2.6
 
Tupperware
TupperwareTupperware
Tupperware
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
 
Puppet and Openshift
Puppet and OpenshiftPuppet and Openshift
Puppet and Openshift
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
Rust vs. Go: qual è il linguaggio più adatto al tuo progetto?
Rust vs. Go: qual è il linguaggio più adatto al tuo progetto?Rust vs. Go: qual è il linguaggio più adatto al tuo progetto?
Rust vs. Go: qual è il linguaggio più adatto al tuo progetto?
 
Open Social Data (Jaca), Alejandro Rivero
Open Social Data (Jaca), Alejandro RiveroOpen Social Data (Jaca), Alejandro Rivero
Open Social Data (Jaca), Alejandro Rivero
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
Nginx-lua
Nginx-luaNginx-lua
Nginx-lua
 
Spark Day 2017- Spark 의 과거, 현재, 미래
Spark Day 2017- Spark 의 과거, 현재, 미래Spark Day 2017- Spark 의 과거, 현재, 미래
Spark Day 2017- Spark 의 과거, 현재, 미래
 

Viewers also liked

Camping og facebook_til_download
Camping og facebook_til_downloadCamping og facebook_til_download
Camping og facebook_til_download
Rasmus Hamann
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
weerachai99
 
Arro capabilities lean revised 2010
Arro capabilities   lean revised 2010Arro capabilities   lean revised 2010
Arro capabilities lean revised 2010
fileserve
 
Apu presentation
Apu presentationApu presentation
Apu presentation
clhatfield
 
Algorithm Final Presentation
Algorithm Final PresentationAlgorithm Final Presentation
Algorithm Final Presentation
Johnson Chou
 
Luat thue thu nhap ca nhan 2007
Luat thue thu nhap ca nhan 2007Luat thue thu nhap ca nhan 2007
Luat thue thu nhap ca nhan 2007
Tiggy Ng
 
Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?
YahooUK
 

Viewers also liked (20)

Camping og facebook_til_download
Camping og facebook_til_downloadCamping og facebook_til_download
Camping og facebook_til_download
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
 
General Catalog GFS Indonesia
General Catalog GFS IndonesiaGeneral Catalog GFS Indonesia
General Catalog GFS Indonesia
 
The perng mha ngan box
The perng mha ngan boxThe perng mha ngan box
The perng mha ngan box
 
видеокамера сони
видеокамера сонивидеокамера сони
видеокамера сони
 
Nicholas John Spykman
Nicholas John SpykmanNicholas John Spykman
Nicholas John Spykman
 
Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...
Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...
Membangun Nasionalisme melalui Upacara Bendera - Universitas Katolik Parahyan...
 
Quotationsanddialogue 2014
Quotationsanddialogue 2014Quotationsanddialogue 2014
Quotationsanddialogue 2014
 
FA Catalog
FA CatalogFA Catalog
FA Catalog
 
Arro capabilities lean revised 2010
Arro capabilities   lean revised 2010Arro capabilities   lean revised 2010
Arro capabilities lean revised 2010
 
Apu presentation
Apu presentationApu presentation
Apu presentation
 
Showdonttell
ShowdonttellShowdonttell
Showdonttell
 
Algorithm Final Presentation
Algorithm Final PresentationAlgorithm Final Presentation
Algorithm Final Presentation
 
Reading
ReadingReading
Reading
 
Luat thue thu nhap ca nhan 2007
Luat thue thu nhap ca nhan 2007Luat thue thu nhap ca nhan 2007
Luat thue thu nhap ca nhan 2007
 
пдд азербайджана
пдд азербайджанапдд азербайджана
пдд азербайджана
 
Gallus2002 usermanual
Gallus2002 usermanualGallus2002 usermanual
Gallus2002 usermanual
 
Nokia n9 ug_ru
Nokia n9 ug_ruNokia n9 ug_ru
Nokia n9 ug_ru
 
Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?Internet Week Yahoo! Academy: How Direct Can You Be?
Internet Week Yahoo! Academy: How Direct Can You Be?
 
Wallander - Becka
Wallander - BeckaWallander - Becka
Wallander - Becka
 

Similar to Integrate gitolite with mantis

Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 
Git the Wnderfull tool
Git the Wnderfull toolGit the Wnderfull tool
Git the Wnderfull tool
Amitoj Singh
 
Git Workshop : Git On The Server
Git Workshop : Git On The ServerGit Workshop : Git On The Server
Git Workshop : Git On The Server
Wildan Maulana
 

Similar to Integrate gitolite with mantis (20)

Advanted git
Advanted git Advanted git
Advanted git
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git the Wnderfull tool
Git the Wnderfull toolGit the Wnderfull tool
Git the Wnderfull tool
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git Workshop : Git On The Server
Git Workshop : Git On The ServerGit Workshop : Git On The Server
Git Workshop : Git On The Server
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Github basics
Github basicsGithub basics
Github basics
 
Getting started with git
Getting started with gitGetting started with git
Getting started with git
 
Git Primer
Git PrimerGit Primer
Git Primer
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Git basics
Git basicsGit basics
Git basics
 
Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Git github
Git githubGit github
Git github
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Integrate gitolite with mantis

  • 1. Integrate Gitolite with Mantis Jiahe Jou, 2012/08/31
  • 2. Revisions DATE Author DESCRIPTION 2012/08/31 Jiahe Jou Draft.
  • 3. Outlines ● Main Idea of Synchronizing to Mantis ● Git Hooks Procedure ● Gitolite Common Hooks ● Intermediate Programs ● Send SMTP Mail
  • 4. Main Idea of Synchronizing to Mantis User Git Push Gitolite Post Hooks Intermediate Programs Mantis
  • 5. Git Hooks Procedure ● The hooks procedure after git push: Receive Objects Post-commit Hook Post-receive Hook Pre-receive Hook Post-update Hook Update Repository
  • 6. Gitolite Common Hooks ● /usr/share/gitolite/hooks/common/* ● post-receive: ... # read input objects while read oldrev newrev ref do # get the commit information subj=`git show -s --format="%s" $newrev` diff=`git show $newrev...$oldrev` msgs="$subj $diff" # excute pre-write perl script to sync mantis /home/gitolite/git2mantis.pl "$msgs" ... done
  • 7. Gitolite Common Hooks ● Execute "gl-setup" to push common hooks to each repository ● Check whether hook scripts are pushed to each repositories ● Location: ~/repositories/*/hooks/*
  • 8. Intermediate Programs ● /home/gitolite/git2mantis.pl #!/usr/bin/perl # # admin's ssh key must setup in 192.168.0.1 # to log-in automatically. $host = "admin@192.168.0.1"; $sshcmd = "/usr/bin/ssh "; $phpcmd = "/usr/bin/php"; $checkincmd = "/var/www/mantis/scripts/git-checkin.php"; $msg = $ARGV[0]; # excute remote programs through ssh `$sshcmd $host $phpcmd $checkincmd <<< "$msg"`;
  • 9. Intermediate Programs ● Mantis Server: 192.168.0.1: /var/www/mantis/scripts/git-checkin.php ... # Parsing the input to get issue number $t_commit_regexp = "/issueD*(d*)/"; $t_line = readline(""); iif (preg_match( $t_commit_regexp, $t_line, $t_matches ) == 0) { echo "Comment does not reference any issues.n"; exit( 0 ); } $t_issues[0] = $t_matches[1]; ... # Call mantis helper function to insert issue note $t_issue_id = $t_issues[0]; helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment, $t_history_old_value, $t_history_new_value, false );
  • 10. Send SMTP Mail ● Modify ~/.gitolite/conf/gitolite.conf to add mailing list with "hooks.mailinglist" ... repo testing config hooks.mailinglist = "alex.lin@innocomm.com, cc. chen@innocomm.com, cookie.liu@innocomm.com, ... jiahe.jou@innocomm.com, weili.luo@innocomm.com" RW+ = @all R = daemon R = gitweb ...
  • 11. Send SMTP Mail ● Add the following to post-receive ... # get mailing list by git config recipients=`git config hooks.mailinglist` # execute pre-write script to send mail /home/gitolite/git2mail.py "$subj" "$diff" "$recipients" ...
  • 12. Send SMTP Mail ● Send mail through SMTP with gmail #!/usr/bin/python import sys import smtplib subject = sys.argv[1] body = sys.argv[2] recipients = sys.argv[3] gmail_user = 'admin@gmail.com' gmail_pwd = 'password' smtpserver = smtplib.SMTP("smtp.gmail.com",587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo() smtpserver.login(gmail_user, gmail_pwd) header = 'To:' + recipients + 'n' + 'From: ' + gmail_user + 'n' + 'Subject: [Gitolite] ' + subject + ' n' msg = header + 'n' + body + 'nn' smtpserver.sendmail(gmail_user, recipients.split(', '), msg) smtpserver.close()