Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clementallen/smithers
Async Jenkins API client for browsers and node
https://github.com/clementallen/smithers
api hacktoberfest jenkins jenkins-ci promise
Last synced: about 1 month ago
JSON representation
Async Jenkins API client for browsers and node
- Host: GitHub
- URL: https://github.com/clementallen/smithers
- Owner: clementallen
- License: mit
- Created: 2017-04-11T10:36:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-03T04:48:56.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T16:16:14.075Z (7 months ago)
- Topics: api, hacktoberfest, jenkins, jenkins-ci, promise
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/smithers
- Size: 1.68 MB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Smithers
Async Jenkins API client for browsers and node
[![npm version](https://badge.fury.io/js/smithers.svg)](https://badge.fury.io/js/smithers)
[![Build Status](https://travis-ci.org/clementallen/smithers.svg?branch=master)](https://travis-ci.org/clementallen/smithers)
[![Coverage Status](https://coveralls.io/repos/github/clementallen/smithers/badge.svg?branch=master)](https://coveralls.io/github/clementallen/smithers?branch=master)
[![dependencies Status](https://david-dm.org/clementallen/smithers/status.svg)](https://david-dm.org/clementallen/smithers)
[![devDependencies Status](https://david-dm.org/clementallen/smithers/dev-status.svg)](https://david-dm.org/clementallen/smithers?type=dev)### **Note:** This package is under active development and while the version is less than 1.x.x all releases should be treated as containing breaking changes.
## Install
```bash
$ npm install --save smithers
```## Usage
### Setup
#### Basic setup - no authentication (config optional)
```javascript
import Smithers from 'smithers';const smithers = new Smithers('https://jenkinsurl.com', config);
```#### Username & password/token auth (config.auth required)
```javascript
import Smithers from 'smithers';const smithers = new Smithers('https://jenkinsurl.com', {
auth: {
username: 'username',
password: 'password/token'
}
});
```### Configuration
Configuration can be either passed when Smithers is instantiated or when a method is called. The configuration is forwarded to the `axios` calls so look at the [axios documentation](https://github.com/mzabriskie/axios#request-config) to see the different options.
- **crumbIssuer** `Boolean` `default=false`: Enables CSRF crumb support for post requests
- **timeout** `Number` `default=5000`: Request timeout in milliseconds### Methods
_Note: These examples are using `async/await` but work perfectly with `.then` and `.catch` as well_
#### getInfo()
- **config** `Object` optional
Retrieves all data from the `/api/json` endpoint.
```javascript
await smithers.getInfo([config]);
```#### getJobInfo()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves all data from a specific job
```javascript
await smithers.getJobInfo(jobName, [config]);
```#### startBuild()
- **jobName** `String` **required**
- **config** `Object` optionalTriggers a build for the specific job
```javascript
await smithers.startBuild(jobName, [config]);
```#### stopBuild()
- **jobName** `String` **required**
- **buildNumber** `Number` **required**
- **config** `Object` optionalStops the build of a specifc job
```javascript
await smithers.stopBuild(jobName, buildNumber, [config]);
```#### getLastBuild()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves all data from the latest build of a specifc job
```javascript
await smithers.getLastBuild(jobName, [config]);
```#### getLastSuccessfulBuild()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves all data from the latest successful build of a specifc job
```javascript
await smithers.getLastSuccessfulBuild(jobName, [config]);
```#### getLastStableBuild()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves all data from the latest stable build of a specifc job
```javascript
await smithers.getLastStableBuild(jobName, [config]);
```#### getLastUnsuccessfulBuild()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves all data from the latest unsuccessful build of a specifc job
```javascript
await smithers.getLastUnsuccessfulBuild(jobName, [config]);
```#### getLastFailedBuild()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves all data from the latest unsuccessful build of a specifc job
```javascript
await smithers.getLastFailedBuild(jobName, [config]);
```#### getSpecificBuild()
- **jobName** `String` **required**
- **buildNumber** `Number` **required**
- **config** `Object` optionalRetrieves all data for a specific build of a specifc job
```javascript
await smithers.getSpecificBuild(jobName, buildNumber, [config]);
```#### getConfigXML()
- **jobName** `String` **required**
- **config** `Object` optionalRetrieves the XML config of a specifc job
```javascript
await smithers.getConfigXML(jobName, [config]);
```#### getOverallLoad()
- **config** `Object` optional
Retrieves statistics of the entire system (busy executors, queue length, etc...)
```javascript
await smithers.getOverallLoad([config]);
```#### getQueue()
- **config** `Object` optional
Retrieves all data about the current queue
```javascript
await smithers.getQueue([config]);
```#### getView()
- **viewName** `String` `default='All'` optional
- **config** `Object` optionalRetrieves all data about a specific view or the default view of 'All'
```javascript
await smithers.getView(viewName, [config]);
```#### restart()
- **config** `Object` optional
Restarts Jenkins
```javascript
await smithers.restart([config]);
```#### safeRestart()
- **config** `Object` optional
Restarts Jenkins once no jobs are running
```javascript
await smithers.safeRestart([config]);
```#### startQuietDown()
- **config** `Object` optional
Starts "quiet down" mode
```javascript
await smithers.startQuietDown([config]);
```#### stopQuietDown()
- **config** `Object` optional
Stops "quiet down" mode
```javascript
await smithers.stopQuietDown([config]);
```#### getWhoAmI()
- **config** `Object` optional
Retrieves user details
```javascript
await smithers.getWhoAmI([config]);
```#### getUser()
- **user** `String` **required**
- **config** `Object` optionalRetrieves all data about a specific user
```javascript
await smithers.getUser(user, [config]);
```