triggers

Polling servers to see if there are changes is not cool anymore, event driven architectures are all the rage.

It is recommended to have version control systems push to linci to tell it to build, rather than for linci to poll the vcs.

Most vcs will let you run a simple command after a commit i.e.

linci build myproject

If your linci server is not in the same machine as the vcs server write a little ssh script.

nohup ssh ci@ci "linci build myproject" 2>/dev/null 1>/dev/null &

p4 triggers

Perforce trigger syntax is simple. Using the p4 triggers command you can specify the trigger name, event, source location and quoted comand or script to run.

Triggers:
	myproject change-commit //depot/myproject/... "linci build myproject"
If your linci server is not in the same machine as the vcs server write a little ssh script.
nohup ssh ci@ci "linci build myproject" 2>/dev/null 1>/dev/null &

git hooks

Git hooks are scripts run after (or before) certain events. This page describes git hooks git hooks.

github.com webhooks

Web hooks are a fair bit more complicated than hooks that run scripts, you have to implement a REST interface, example below.

This page describes github webhooks.

There is a project on npm github-webhook-handler which makes life a little easier. Example github-webhook.js

var http = require('http');
var spawn = require('child_process').spawn;
var createHandler = require('github-webhook-handler');

/**
 * npm install github-webhook-handler
 */

/**
 * Map from github repository name to the linci build to execute.
 */
var buildMap = {
	
	// github //       // linci //
	
	'arp'          :    'arp',
	'rewrite'      :    'rewrite',
	'mod-upload'   :    'modupload'
	
};

var handler = createHandler({
	path: '/webhook',
	secret: 'myhashsecret' 
});

http.createServer(function (req, res) {
	
	handler(req, res, function (err) {
		res.statusCode = 404;
		res.end("NOT FOUND");
	});
	
}).listen(8888, function() {
	console.log("Listening on : 8888");
});

handler.on('error', function (err) {
	console.error("Error:", err.message);
});

/**
 * push handler - runs linci build xxx in response to a git push.
 */
handler.on('push', function (event) {
	
	console.log('Received a push event for %s to %s', event.payload.repository.name, event.payload.ref);
	
	var child = spawn('linic', ['build', buildMap[event.payload.repository.name] ], {
		detached: true,
		stdio: [ 'ignore', out, err ]
	});
	child.unref();
	
});

handler.on('issues', function (event) {
	// you might want to run test jobs here if issues are closed.
});

svn

Subversion supports repository side hooks.

bazaar

bazaar users have to write a bit of python.

polling

If you really need to poll servers do so in bash and if your script is tidy and generic it can be addded to linci distributions. VCS polling is not something linci project is going to spend time on.




P.S. see easy it is for projects that follow Unix best practices and how much more complicated it is for these hipsters that use python and REST!