# grunt-circleci

> Grunt plugin to check CircleCI build status

Latest version **0.2.0** (published 2017-10-21) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install grunt-circleci
pnpm add grunt-circleci
yarn add grunt-circleci
bun add grunt-circleci
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-10-21 |
| First published | 2014-09-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | VividCortex |
| Maintainers | mtrias, iambrosi |
| Keywords | gruntplugin, circleci |

## Links

- npm: https://www.npmjs.com/package/grunt-circleci
- Repository: https://github.com/VividCortex/grunt-circleci
- Issues: https://github.com/VividCortex/grunt-circleci/issues
- npm.io page: https://npm.io/package/grunt-circleci

## Dependencies (2)

- [q](https://npm.io/package/q.md) ^1.0.1
- [circleci](https://npm.io/package/circleci.md) ^0.1.1

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2017-10-21
- 0.1.3 — 2016-11-04
- 0.1.2 — 2015-03-23
- 0.1.1 — 2014-09-26

## README

# 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 app deploy.


## Getting started

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
npm install grunt-circleci --save-dev
```


Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-circleci');
```


## Configuration

In order to configure the plugin, you need to add a new section `circleci` to the object in `grunt.initConfig()`.


```js
grunt.initConfig({
  circleci: {
    token:    'MySuperSecretTokenGeneratedOnCircleCI'
    username: 'VividCortex',
    project:  'grunt-circleci',
    commit:   'TheHashOfTheCommit'
  }
});
```

### Available options


The following options allow to customize the behaviour of the status check:

#### options.branch

Type `String`
Default: `master`

The name of the branch by which to filter the builds.

#### options.retryOnRunning

Type `Boolean`
Default: `false`

Whether the check should retry or not if the build is currently running.

#### options.retryAfter

Type `Number`
Default: `20000` (20 seconds)

The time in milliseconds the check should wait to retry if _retryOnRunning_ is enabled.

#### options.timeout

Type `Number`
Default: `600000` (10 minutes)

The time in milliseconds after which the check should fail if the build is still running and _retryOnRunning_ is enabled.


### Full example

```js
grunt.initConfig({
  circleci: {
    token:    'MySuperSecretTokenGeneratedOnCircleCI'
    username: 'VividCortex',
    project:  'grunt-circleci',
    commit:   'TheHashOfTheCommit',
    options: {
      branch:         'master',
      retryOnRunning: false,
      retryAfter:     2e4,
      timeout:        6e5
    }
  }
});
```

## Usage

The basic usage requires you to execute the following simple command:

```
grunt circleci
```

If grunt is configured properly, you can use custom values for the commit hash, for instance:

```js
grunt.initConfig({
  circleci: {
    token:    'MySuperSecretTokenGeneratedOnCircleCI'
    username: 'VividCortex',
    project:  'grunt-circleci',
    commit:   grunt.option('commit')
  }
});
```

and run the command as:

```
grunt circleci --commit=TheHashOfTheCommit
```

### 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.

---
_Source: https://npm.io/package/grunt-circleci · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
