grunt-circleci
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "grunt-circleci", | ||
"description": "Grunt plugin to check CircleCI build status", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/VividCortex/grunt-circleci", | ||
@@ -6,0 +6,0 @@ "author": "VividCortex", |
@@ -1,5 +0,5 @@ | ||
# grunt-circleci ![Build Status](https://circleci.com/gh/VividCortex/grunt-circleci.svg?circle-token=ffc337cb4ff22c2f70947954886e9012e0f2468f) | ||
# grunt-circleci [![Circle CI](https://circleci.com/gh/VividCortex/grunt-circleci.png?style=badge)](https://circleci.com/gh/VividCortex/grunt-circleci) | ||
This plugin allows to check the status of a CircleCI build associated to a commit. Useful for apps that need to check for a successful status before running a critical task, like the deploy. | ||
This plugin allows to check the status of a CircleCI build associated to a commit. Useful for apps that need to check for a successful status before running a critical task, like the app deploy. | ||
@@ -9,4 +9,6 @@ | ||
First, you need to add the dependency and install it into your project. | ||
This plugin requires Grunt `~0.4.0` | ||
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](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: | ||
```js | ||
@@ -17,3 +19,4 @@ npm install grunt-circleci --save-dev | ||
Once intalled, it can be loaded in your _Gruntfile_ with the follwing line: | ||
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: | ||
```js | ||
@@ -120,3 +123,30 @@ grunt.loadNpmTasks('grunt-circleci'); | ||
### Getting the commit hash | ||
[grunt-gitinfo](https://www.npmjs.org/package/grunt-gitinfo) is a very useful plugin for grunt that allows to fetch some information about your GIT repository. By using it, you will be able to check the status for the latest commit. | ||
```js | ||
grunt.initConfig({ | ||
// ... | ||
gitinfo: {}, | ||
circleci: { | ||
// ... | ||
// Use the commit hash | ||
commit: '<%= gitinfo.local.branch.current.SHA %>' | ||
} | ||
}); | ||
// Get the repo information before checking the status | ||
grunt.registerTask('check-build', ['gitinfo', 'circleci']); | ||
``` | ||
And then, run the following command to check the status: | ||
``` | ||
grunt check-build | ||
``` | ||
## License | ||
Copyright (c) 2014 VividCortex. Licensed under the MIT license. |
@@ -29,3 +29,3 @@ 'use strict'; | ||
Build.prototype.isRunning = function () { | ||
return -1 !== ['running', 'scheduled'].indexOf(this.getStatus()); | ||
return -1 !== ['running', 'scheduled', 'queued', 'not_running'].indexOf(this.getStatus()); | ||
}; | ||
@@ -32,0 +32,0 @@ |
@@ -21,2 +21,16 @@ 'use strict'; | ||
'running on status "queued"': function (test) { | ||
var build = new Build({status: 'queued'}); | ||
test.strictEqual(build.isRunning(), true, 'should report as running when status is "queued"'); | ||
test.done(); | ||
}, | ||
'running on status "not_running"': function (test) { | ||
var build = new Build({status: 'not_running'}); | ||
test.strictEqual(build.isRunning(), true, 'should report as running when status is "not_running"'); | ||
test.done(); | ||
}, | ||
'success on status "success"': function (test) { | ||
@@ -23,0 +37,0 @@ var build = new Build({status: 'success'}); |
501
150
24198
15