I have a javascript project which uses Grunt and several plug-ins such as:

Not all of the developers run the grunt tasks locally (e.g. jshint, qunit), so they might not know if code they committed has issues. It's easy enough to set up a grunt watch task, but emailing the team upon error/warning has been less obvious than I expected.

I was expecting to find something like grunt-contrib-emailstatus for emailing a nicely-formatted status, but so far have not come across this. Did I miss it?

If not, what's the recommended practice here? In the past I've seen things like Cruise Control, Jenkins, or Hudson handle the build status reporting, but it seems like too big a hammer for this nail. And on the other hand, trying to use crontab to email status seems too small.


What I did in my team is:

  • We use git, so I've setup a git commit hook. So each time that you commit Grunt runs jshint. If it fails you cannot commit.

    • Good: A lot of times I forgot to run jshint by hand. So a commit failure is the best reminder.
    • Bad: Commit hook means: commit to your git repo (not receiving a push on the origin). So you need to setup the commit hook locally (I've created a grunt task for that). Because of that the effectiveness of the approach depends on each developer honesty (also you can force the commit without running the hooks). Another con: If you use some Git UI, you need to properly setup the PATH so the program can run the commit hook without errors. But setting up the PATH for UI in MacOSX is not so easy (lots of changes in that area between MacOSX versions)
  • We use Jenkins. So the build fails if jshint or the unit tests fails. Yes it's a "big hammer", but these tools are designed for that kind of continuos integration tasks. You can use them for other kind of stuff like creating your production bundle, or doing some functional tests using real web browsers. For example we use Jenkins hosted on Cloudbees and we trigger some functional tests based on SauceLabs.

Also it's possible to setup a server side commit hook. I couldn't do that since we use Github and we don't control the git server (Github offers that functionality by connecting third party apps to your repo, like Travis CI).

But if you control your git repo, and you don't want to use a big CI tool, you can setup a post-receive hook that (http://git-scm.com/book/en/Customizing-Git-Git-Hooks) that fires the verification on background and sends the email (basically you are writing a home-brew CI tool in that case ;) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.