{"_id":"543c7b1fe443e3080085b30d","__v":24,"user":"543c76fbe443e3080085b2eb","project":"543c7b1fe443e3080085b307","version":{"_id":"543c7b1fe443e3080085b30a","__v":1,"project":"543c7b1fe443e3080085b307","createdAt":"2014-10-14T01:23:43.311Z","releaseDate":"2014-10-14T01:23:43.311Z","categories":["543c7b1fe443e3080085b30b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"543c7b1fe443e3080085b30b","__v":7,"project":"543c7b1fe443e3080085b307","pages":["543c7b1fe443e3080085b30d","543c8bdea41afe0e00c4facc","543c8c23a41afe0e00c4face","543c8da2a41afe0e00c4fad8","543c8cd2a41afe0e00c4fad2"],"version":"543c7b1fe443e3080085b30a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-14T01:23:43.398Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"is_link":false,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-14T01:23:43.506Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"try":true,"basic_auth":false,"results":{"codes":[]},"auth":"never","params":[],"url":""},"isReference":false,"order":0,"body":"[![status](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/status.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![Dependency Status](https://david-dm.org/logankoester/grunt-hipchat-notifier.png)](https://david-dm.org/logankoester/grunt-hipchat-notifier)\n[![devDependency Status](https://david-dm.org/logankoester/grunt-hipchat-notifier/dev-status.png)](https://david-dm.org/logankoester/grunt-hipchat-notifier#info=devDependencies)\n[![Gittip](http://img.shields.io/gittip/logankoester.png)](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[![NPM](https://nodei.co/npm/grunt-hipchat-notifier.png?downloads=true)](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[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/logankoester/grunt-hipchat-notifier/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n[![xrefs](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/xrefs.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![funcs](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/funcs.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![top func](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/top-func.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![library users](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/library-users.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![authors](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/authors.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![Total views](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/counters/views.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)\n[![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/counters/views-24h.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)","excerpt":"Send grunt messages to a Hipchat channel","slug":"getting-started","type":"basic","title":"Getting Started"}

Getting Started

Send grunt messages to a Hipchat channel

[![status](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/status.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![Dependency Status](https://david-dm.org/logankoester/grunt-hipchat-notifier.png)](https://david-dm.org/logankoester/grunt-hipchat-notifier) [![devDependency Status](https://david-dm.org/logankoester/grunt-hipchat-notifier/dev-status.png)](https://david-dm.org/logankoester/grunt-hipchat-notifier#info=devDependencies) [![Gittip](http://img.shields.io/gittip/logankoester.png)](https://www.gittip.com/logankoester/) ### Install with npm If 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: [block:code] { "codes": [ { "code": "npm install grunt-hipchat-notifier --save-dev", "language": "shell", "name": "Install" } ] } [/block] Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: [block:code] { "codes": [ { "code": "module.exports = function(grunt) {\n\tgrunt.loadNpmTasks('grunt-hipchat-notifier');\n}", "language": "javascript", "name": "Gruntfile.js" } ] } [/block] [![NPM](https://nodei.co/npm/grunt-hipchat-notifier.png?downloads=true)](https://nodei.co/npm/grunt-hipchat-notifier/)' [block:api-header] { "type": "basic", "title": "Global Options" } [/block] Set 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. [block:parameters] { "data": { "0-0": "**authToken**", "0-1": "*String*", "0-2": "Create an authToken at https://hipchat.com/admin/api", "1-0": "**roomId**", "1-1": "*String*", "1-2": "Numeric Hipchat roomId or room name", "h-0": "Field", "h-1": "Type", "h-2": "Description" }, "cols": 3, "rows": 2 } [/block] In your project's Gruntfile, add a section named *hipchat_notifier* to the data object passed into **grunt.initConfig()**. #### Your Gruntfile should look like this... [block:code] { "codes": [ { "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}", "language": "javascript", "name": "Gruntfile.js" } ] } [/block] [block:api-header] { "type": "basic", "title": "Message Options" } [/block] [block:parameters] { "data": { "0-0": "**message**", "0-2": "A message to send", "0-1": "*String*", "1-0": "**from**", "1-1": "*String*", "1-2": "Name for the sender", "2-0": "**color**", "2-1": "*String*", "2-2": "Color of the message", "3-0": "**message_format**", "3-2": "Can either be 'text' or 'html' format", "3-1": "*String*", "h-0": "Field", "h-1": "Type", "h-2": "Description" }, "cols": 3, "rows": 4 } [/block] [block:api-header] { "type": "basic", "title": "Create a static message" } [/block] [block:code] { "codes": [ { "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});", "language": "javascript", "name": "Gruntfile.js" } ] } [/block] Create as many messages as you like! [block:api-header] { "type": "basic", "title": "Create a dynamic message" } [/block] Build a message at runtime using JavaScript, to include more information about the event. [block:code] { "codes": [ { "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});", "language": "javascript", "name": "Gruntfile.js" } ] } [/block] [block:callout] { "type": "success", "title": "Triggering notifications from JavaScript", "body": "```javascript\ngrunt.task.run(\"hipchat_notifier:hello_grunt\");\n```" } [/block] [block:callout] { "type": "info", "title": "Triggering notifications from the console", "body": "```bash\n$ grunt hipchat_notifier:hello_grunt\n```" } [/block] ## Release History * 0.3.0 - Updated to use new hipchat-client format (deprecated sendRoomMessage) (thanks [@ksykulev](https://github.com/ksykulev)!) * 0.2.2 - Updated hipchat-client, fixes syntax error in example * 0.2.1 - Updated hipchat-client - roomId can now be either numeric or room name. * 0.2.0 - Added support for Hipchat message_format to allow for emoticons and @mentions * 0.1.1 - Added support for dynamic messaging * 0.1.0 - First release [block:image] { "images": [ { "image": [ "https://files.readme.io/22GNDvM6QEqNUpQbPfu0_grunt-hipchat-notifier.png", "grunt-hipchat-notifier.png", "369", "184", "", "" ] } ] } [/block] [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/logankoester/grunt-hipchat-notifier/trend.png)](https://bitdeli.com/free "Bitdeli Badge") [![xrefs](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/xrefs.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![funcs](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/funcs.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![top func](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/top-func.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![library users](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/library-users.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![authors](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/badges/authors.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![Total views](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/counters/views.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier) [![Views in the last 24 hours](https://sourcegraph.com/api/repos/github.com/logankoester/grunt-hipchat-notifier/counters/views-24h.png)](https://sourcegraph.com/github.com/logankoester/grunt-hipchat-notifier)