Repository Push/Commit Notifications

Last updated by Adam West on April 11, 2018 15:11

Codebase supports sending HTTP notifications to a URL when a repository is pushed (Git/Mercurial/Bazaar) or committed (Subversion) to. This allows Codebase to be integrated with 3rd party applications or your own scripts and can be useful for activities like automatically triggering a deployment to your production servers when a new commit is made.

In addition to HTTP notifications it is possible to specify an email address in the endpoint field to receive email notifications when a repository is pushed or committed to.

Setting up Notifications

Navigate to the repository you wish to create a notification on and select Settings on the right hand side of the page:

Once here, change the tab to Post-Receive Hooks. You can now enter your HTTP url or email address in the text box provided. If HTTP Authentication is required then click Add HTTP authentication details from below the text box.

Click Add and the next time your repository receives a push or commit your endpoint should receive a notification.

Data Format

HTTP post-receive notifications deliver JSON containing information about the commits in the push and the repository in general, some example data is listed below with annotations:

{    
	"before":"fc10b3aa5a9e39ac326489805bba5c577f04db85", // Commit ref before the push    	   	  
	"after":"840daf31f4f87cb5cafd295ef75de989095f415b", // Commit ref after the push    	 
	"ref":"refs/heads/master", // Branch of the push    
	"repository":{       
		"name":"Git Repo #1", // Friendly repository name       		 
		"url":"">">http://test.codebasehq.com/projects/test-repositor... href="http://test.codebasehq.com/projects/test-repositor...">http://test.codebasehq.com/projects/test-repositor... href="">http://test.codebasehq.com/projects/test-repositor...">http://test.codebasehq.com/projects/test-repositor... href="">http://test.codebasehq.com/projects/test-repositor...">http://test.codebasehq.com/projects/test-repositor...">http://test.codebasehq.com/projects/test-repositor... ,"="">http://test.codebasehq.com/projects/test-repositor...">http://test.codebasehq.com/projects/test-repositor... // URL to repository browser in Codebase       
		"clone_url":"git@codebasehq.com:test/test-repositories/git1.git",  // Default clone URL       
		"clone_urls":{         
			 "ssh":"git@codebasehq.com:test/test-repositories/git1.git", // SSH clone URL          
			 "git":"git://codebasehq.com:test/test-repositories/git1.git", // git:// clone URL
		          "http":"">https://test.codebasehq.com/test-repositories/git1...">https://test.codebasehq.com/test-repositories/git1... "="">https://test.codebasehq.com/test-repositories/git1... // HTTP clone URL       
		},       
		"project":{         
			 "name":"Test Repositories", // Containing project friendly name          
			 "url":"http://test.codebasehq.com/projects/test-repositor... ,"="">http://test.codebasehq.com/projects/test-repositor... // Containing project URL
		         "status":"active" // Containing project status       
		}    
	},    
	"user":{       
		"name":"Dan Wentworth", // Name of user who performed the push       
		"username":"dan", // Username of user who performed push       
		"email":"dan@atechmedia.com" // Email address of person who performed push    
	},    
	"commits":[ // Array of commits in a push       
		{          
			"id":"840daf31f4f87cb5cafd295ef75de989095f415b", // Ref of commit          
			"message":"Extra output for the rrrraaaagh", // Commit message          
			"author":{             
				"name":"Dan Wentworth", // Commit author             
				"email":"dan@atechmedia.com" // Commit email address          
			},          
			"timestamp":"Mon, 18 Jul 2011 10:50:01 +0100", // Date/Time of commit          
			"url":"http://test.codebasehq.com/projects/test-repositor... "="">http://test.codebasehq.com/projects/test-repositor... }] 
}