Inspired by jenkins / hudson