Skip to content

Instantly share code, notes, and snippets.

View hellgrenj's full-sized avatar

Johan Hellgren hellgrenj

View GitHub Profile
@hellgrenj
hellgrenj / run custom node.js script on git pre-commit
Created July 11, 2016 16:18
run custom node.js script on git pre-commit
#!/bin/sh
# run script to check if commit is valid
# you can run anything here, I happen to use a node script
# make sure to exit with 0 (success) if everything is ok and 1 (failure) if not.
# In a custom node.js script you do that like so: process.exit(code = 1);
node ./my_custom_test_runner.js
RETVAL=$?
#ECHO $RETVAL
@hellgrenj
hellgrenj / exampleHulkenRunnerScript.js
Last active July 11, 2016 15:49
example hulken runner script
var hulken = require('hulken');
var hulken_options = {
targetUrl: 'http://localhost:8888',
numberOfHulkenAgents: 20,
timesToRunEachRequest: 30,
requestsFilePath: './auto-generated-requests-file.json',
tokensSkippingRequest: [':', '*', '{', '}'],
requestsToSkip: ['/logout', '/some-other-endpoint'],
loginRequired: true,
@hellgrenj
hellgrenj / how to automate a clean git pull from Bitbucket
Last active July 11, 2016 15:39
how to automate a clean git pull from Bitbucket
/*
using shelljs and shelljs.exec() and checking response code do:
git reset --hard HEAD
git clean -f
git pull origin <branch name>
you have to set up a deployment key: https://confluence.atlassian.com/bitbucket/use-deployment-keys-294486051.html
example:
@hellgrenj
hellgrenj / simpleBitbucketWebhookEndpoint.js
Last active June 26, 2020 21:04
Simple Bitbucket webhook endpoint (with hapi.js)
var Hapi = require('hapi');
var worker = require('./worker'); // custom script to pull down code, run tests, restart services etc..
var server = new Hapi.Server();
server.connection({
port: 1337
});
server.route({
method: 'POST',
path: '/',
handler: function(request, reply) {