# grunt-idra

> Grunt Plugin for IBM DevOps Deployment Risk Analyzer

Latest version **0.0.43** (published 2015-12-09) · 0 weekly downloads

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

## Install

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

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.43 |
| Published | 2015-12-09 |
| First published | 2015-08-12 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Umesh Parulekar |
| Maintainers | umesh.parulekar |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-idra
- npm.io page: https://npm.io/package/grunt-idra

## Dependencies (3)

- [extend](https://npm.io/package/extend.md) ^3.0.0
- [request](https://npm.io/package/request.md) *
- [valid-url](https://npm.io/package/valid-url.md) ^1.0.9

## Recent versions

- 0.0.43 (latest) — 2015-12-09
- 0.0.42 — 2015-12-09
- 0.0.41 — 2015-12-07
- 0.0.39 — 2015-12-03
- 0.0.38 — 2015-12-03
- 0.0.36 — 2015-12-02
- 0.0.35 — 2015-11-10
- 0.0.34 — 2015-11-10
- 0.0.33 — 2015-11-10
- 0.0.32 — 2015-11-09
- 0.0.31 — 2015-10-27
- 0.0.30 — 2015-10-27
- 0.0.29 — 2015-10-20
- 0.0.28 — 2015-10-13
- 0.0.27 — 2015-09-16
- … 17 more at https://npm.io/package/grunt-idra/versions

## README

# grunt-idra

> Grunt Plugin for IBM Deployment Risk Analyzer (DRA)

## Getting Started
This plugin requires Grunt `~0.4.5`

This plugin is used to instrument the IDS pipeline to send events and logs to the Deployment Risk Analyzer and to get a decision/risk score from it. You may install this plugin with this command:
```shell
npm install grunt-idra
```

Typical use of this plugin in the pipeline is as follows
```shell
grunt [--gruntfile=<filename>] <command>
where:
   command could be one of the following
     -init=<projectKey>
     -eventType=<eventname>
     -decision=<criterianame>
     -decision=dynamic -criteriafile=<filename>
     -isDRAEnabled
```

### init
The first call to this plugin from the pipeline should be **init**, passing in the projectKey. This step is required for the plugin to work correctly. The call to **init** should be made from the first job of the first stage of the pipeline.
```js
grunt [--gruntfile=>filename>] -init=<projectKey>
```
The projectKey is used as an authorization mechanism. A valid projectKey can be obtained using the DRA register API. The plugin needs the projectKey to successfully communicate with the DRA server.
The project key needs to be provided only once. The only exception to this is if there are multiple jobs set in the first stage of the pipeline, then in addition to calling this plugin with init option (in the first job in the first stage) the project key should also be set as an environment variable in the first stage of the pipeline. The name of the environment variable should be **DRA_PROJECT_KEY**

### eventType
This option is used to log an event to the DRA server. The name of the event is passed to the option. Few additional options can be provided to append more data to the event log.
**-file**
This option takes a file name including the path. Only JSON file type is supported. The contents of the file is sent to the DRA server and logged along with the event data. If the file contains invalid JSON data then this option is ignored.
```js
grunt [--gruntfile=>filename>] -eventType=<some event Name> -file=<path to JSON file name>
```
**-drilldownUrl**
This option a valid url. The value of url is sent to the DRA server and logged along with the event data. If the url is invalid then this option is ignored.
```js
grunt [--gruntfile=>filename>] -eventType=<some event Name> -file=<path to JSON file name> -drilldownUrl=<URL>
grunt [--gruntfile=>filename>] -eventType=<some event Name> -drilldownUrl=<URL>
```

### decision
This option is used to get a decision from the DRA based on the logged data and a criteria whose name is provided as the value of this option. The response of this call is a JSON data, sample is shown below. The important value in the response is the value of "decision" attribute. It could be either "proceed" or "stop"
```js
grunt [--gruntfile=>filename>] -decision=<some criteria name>
```

### dynamic decision
This option is used to get a decision from the DRA based on the logged data and a dynamic criteria. A dynamic criteria is criteria that is provided to DRA at the time of decision. in other words this criteria is not available (created) in DRA before the decision is called.A JSON file containing the criteria is sent in this decision call. The response of this call is a JSON data, sample is shown below. The important value in the response is the value of "decision" attribute. It could be either "proceed" or "stop"
```js
grunt [--gruntfile=>filename>] -decision=dynamic -criteriafile=<path to JSON file name containing the criteria>
```
```shell
Response of a decision
{"criteriaName":"DRABuildTest",
...,
"score":"100%","decision":"proceed",
...,
"timestamp":"2015-09-08T13:57:38.203Z"}
```

### isDRAEnabled
This option is used to determined if the DRA is enabled for the pipeline.
```js
grunt [--gruntfile=>filename>] -isDRAEnabled
```
```shell
Response:
{"enabled": true}
```

### Connecting to different Deployment Analytics Server
By default the plugin connects to the production deployment analytics server. Use the environment variable **DRA_SERVER** to change the default server. 

## The "idra" task

### Overview
In your Gruntfile, add a section named `idra` to the data object passed into `grunt.initConfig()`.

```js
  grunt.initConfig({
    idra: {
      config :{
        deployAnalyticsServer: 'http://localhost:3999',  // optional
        events: {
          eventname: {   // optional
            attr1: 'somevalue',
            attr2: 'somevalue',
            file: 'path to a json file',
          }
        }
      }
    },
  });

  grunt.loadNpmTasks('grunt-idra');
```

### deployAnalyticsServer:
This value is optional, the plugin connects to a the production Deployment Analytics Server by default, if this value is not provided

### events:
The entries here are optional. The entries here provides a way to specify additional attributes to be passed for an event. Each event can have an attribute named **file**, which when set sends the contents of that file along with the event. Only JSON data type is supported for file. There is no limit to the number of events that can be set here. It is not necessary to specify the event here to use it.


## Release History
_(Nothing yet)_

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