{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"never","try":true,"basic_auth":false,"params":[],"results":{"codes":[]}},"next":{"description":"","pages":[]},"title":"Getting Started","type":"basic","slug":"getting-started","excerpt":"Send grunt messages to a Hipchat channel","body":"[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://david-dm.org/logankoester/grunt-hipchat-notifier)\n[](https://david-dm.org/logankoester/grunt-hipchat-notifier#info=devDependencies)\n[](https://www.gittip.com/logankoester/)\n\n### Install with npm\n\nIf you haven't used [Grunt ](http://gruntjs.com/)before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"npm install grunt-hipchat-notifier --save-dev\",\n \"language\": \"shell\",\n \"name\": \"Install\"\n }\n ]\n}\n[/block]\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"module.exports = function(grunt) {\\n\\tgrunt.loadNpmTasks('grunt-hipchat-notifier');\\n}\",\n \"language\": \"javascript\",\n \"name\": \"Gruntfile.js\"\n }\n ]\n}\n[/block]\n[](https://nodei.co/npm/grunt-hipchat-notifier/)'\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Global Options\"\n}\n[/block]\nSet a global Hipchat token and room to use. You may also set these options on a per-message basis, in case you need to notify a different room for a task.\n[block:parameters]\n{\n \"data\": {\n \"0-0\": \"**authToken**\",\n \"0-1\": \"*String*\",\n \"0-2\": \"Create an authToken at https://hipchat.com/admin/api\",\n \"1-0\": \"**roomId**\",\n \"1-1\": \"*String*\",\n \"1-2\": \"Numeric Hipchat roomId or room name\",\n \"h-0\": \"Field\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\"\n },\n \"cols\": 3,\n \"rows\": 2\n}\n[/block]\nIn your project's Gruntfile, add a section named *hipchat_notifier* to the data object passed into **grunt.initConfig()**. \n\n#### Your Gruntfile should look like this...\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"module.exports = function(grunt) {\\n\\tgrunt.loadNpmTasks('grunt-hipchat-notifier');\\n grunt.initConfig({\\n hipchat_notifier: {\\n options: {\\n authToken: \\\"\\\", // Create an authToken at https://hipchat.com/admin/api\\n roomId: \\\"\\\" // Numeric Hipchat roomId or room name\\n }\\n })\\n}\",\n \"language\": \"javascript\",\n \"name\": \"Gruntfile.js\"\n }\n ]\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Message Options\"\n}\n[/block]\n\n[block:parameters]\n{\n \"data\": {\n \"0-0\": \"**message**\",\n \"0-2\": \"A message to send\",\n \"0-1\": \"*String*\",\n \"1-0\": \"**from**\",\n \"1-1\": \"*String*\",\n \"1-2\": \"Name for the sender\",\n \"2-0\": \"**color**\",\n \"2-1\": \"*String*\",\n \"2-2\": \"Color of the message\",\n \"3-0\": \"**message_format**\",\n \"3-2\": \"Can either be 'text' or 'html' format\",\n \"3-1\": \"*String*\",\n \"h-0\": \"Field\",\n \"h-1\": \"Type\",\n \"h-2\": \"Description\"\n },\n \"cols\": 3,\n \"rows\": 4\n}\n[/block]\n\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Create a static message\"\n}\n[/block]\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"grunt.initConfig({\\n\\n hipchat_notifier: {\\n hello_grunt: {\\n options: {\\n message: \\\"Hello!\\\", // A message to send\\n from: \\\"Grunt\\\", // Name for the sender\\n color: \\\"purple\\\", // Color of the message\\n message_format: \\\"html\\\" // Can either be 'text' or 'html' format\\n }\\n }\\n }\\n});\",\n \"language\": \"javascript\",\n \"name\": \"Gruntfile.js\"\n }\n ]\n}\n[/block]\nCreate as many messages as you like!\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"Create a dynamic message\"\n}\n[/block]\nBuild a message at runtime using JavaScript, to include more information about the event.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"grunt.initConfig({\\n \\n hipchat_notifier: {\\n dynamic_hello_grunt: {\\n options: {\\n message: function() { // Functions must return a string\\n var pkg = grunt.config.data.pkg;\\n return 'Running grunt on ' + pkg.name + ' on version ' + pkg.name;\\n },\\n from: function() { // Return the run-time user, or something more creative.\\n return someUsernameGenerator() || process.env['USER'];\\n },\\n // Change color dynamically based on some global state, function response, etc\\n color: function() {\\n return (grunt.config.data.someBoolean && allIsWell()) ? 'green' : 'red';\\n }\\n }\\n }\\n});\",\n \"language\": \"javascript\",\n \"name\": \"Gruntfile.js\"\n }\n ]\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"success\",\n \"title\": \"Triggering notifications from JavaScript\",\n \"body\": \"```javascript\\ngrunt.task.run(\\\"hipchat_notifier:hello_grunt\\\");\\n```\"\n}\n[/block]\n\n[block:callout]\n{\n \"type\": \"info\",\n \"title\": \"Triggering notifications from the console\",\n \"body\": \"```bash\\n$ grunt hipchat_notifier:hello_grunt\\n```\"\n}\n[/block]\n## Release History\n* 0.3.0 - Updated to use new hipchat-client format (deprecated sendRoomMessage) (thanks [:::at:::ksykulev](https://github.com/ksykulev)!)\n* 0.2.2 - Updated hipchat-client, fixes syntax error in example\n* 0.2.1 - Updated hipchat-client - roomId can now be either numeric or room name.\n* 0.2.0 - Added support for Hipchat message_format to allow for emoticons and @mentions\n* 0.1.1 - Added support for dynamic messaging\n* 0.1.0 - First release\n[block:image]\n{\n \"images\": [\n {\n \"image\": [\n \"https://files.readme.io/22GNDvM6QEqNUpQbPfu0_grunt-hipchat-notifier.png\",\n \"grunt-hipchat-notifier.png\",\n \"369\",\n \"184\",\n \"\",\n \"\"\n ]\n }\n ]\n}\n[/block]\n\n[](https://bitdeli.com/free \"Bitdeli Badge\")\n\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)","updates":[],"order":0,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"543c7b1fe443e3080085b30d","__v":24,"user":"543c76fbe443e3080085b2eb","createdAt":"2014-10-14T01:23:43.506Z","project":"543c7b1fe443e3080085b307","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["543c7b1fe443e3080085b30b"],"_id":"543c7b1fe443e3080085b30a","createdAt":"2014-10-14T01:23:43.311Z","__v":1,"project":"543c7b1fe443e3080085b307","releaseDate":"2014-10-14T01:23:43.311Z"},"category":{"sync":{"isSync":false,"url":""},"pages":["543c7b1fe443e3080085b30d","543c8bdea41afe0e00c4facc","543c8c23a41afe0e00c4face","543c8da2a41afe0e00c4fad8","543c8cd2a41afe0e00c4fad2"],"title":"Documentation","slug":"documentation","order":0,"from_sync":false,"reference":false,"_id":"543c7b1fe443e3080085b30b","__v":7,"project":"543c7b1fe443e3080085b307","version":"543c7b1fe443e3080085b30a","createdAt":"2014-10-14T01:23:43.398Z"},"is_link":false}
Getting Started
Send grunt messages to a Hipchat channel