Post-Receive Hooks

Last updated by Adam West on October 09, 2020 10:08

You can setup post-receive hooks which will allow you to call external URLs whenever you push (or commit in the case of SVN) to your repository.

To add a new hook, visit the Repos page and click the Settings button found on the right hand side.

Then click the Post-Receive Hooks tab:

Enter the URL where the hook will be delivered to, and if you require authenticatation, click Add HTTP authentication details:

  • Username is the username that will be used for basic auth when making the request
  • Password is the password that will be used for basic auth when making the request

Example POST Payload

{   
	"before":"cbb086f8f80a54ab5103d53d461ce8cfbe7a6935",   
	"after":"cbb086f8f80a54ab5103d53d461ce8cfbe7a6935",   
	"ref":"refs/heads/master",   
	"repository":{     
		"name":"GIT",     
		"url":"https://test.codebasehq.com/projects/test/reposito... 
                "clone_url":"git@codebasehq.com:test/repositories/repo.git",     
		"clone_urls":{       
			"ssh":"git@codebasehq.com:test/repositories/repo.git"     
		 },     
		"public_access":false,     
		"private":true,     
		"project":{       
	            "name":"test",
		    "url":"https://test.codebasehq.com/projects/test",                     "status":"active"
		}   
	},   
	"user":{     
		"name":"Dan Quinney",     
		"username":"danq",     
		"email":"danq@atechmedia.com"   
	},   
	"commits":[{
		"id":"479c96510d456f090f9c4f619a396dbf52bd6574",       
		"message":"indexes",
	        "author":{
			"name":"Dan W",
			"email":"dan@atechmedia.com"       
		},       
		"timestamp":"Thu, 04 Apr 2013 16:15:15 +0100",   		
                "url":"https://test.codebasehq.com/projects/test/reposito... 
		"added":[        
			 "db/migrate/20130404151222_add_indexes_to_users.rb"       
		],       
		"removed":[],       
		"modified":[]     
	}],
	"test":true 
}

Diagnosing hook issues

Once your hook has been set up, you can use the "Test" button to check you're able to successfully communicate with the external endpoint, and if needed, hover over the counter on the left-hand side to view the last response if it was an error.