Jenkins JSON API TypeScript Typings
NPM: https://www.npmjs.com/package/jenkins-api-ts-typings
Jenkins: https://www.andreistraut.info/jenkins/view/Jenkins%20TS%20Typings/
This library offers a set of classes to use when working with Jenkins JSON API. Jenkins Job, Build, Actions, Health Report, User, View, Changeset and Node / Computer are supported
In your project’s root folder:
npm install --save jenkins-api-ts-typings
In systemjs.config.js:
map: {
'jenkins-api-ts-typings': 'npm:jenkins-api-ts-typings'
},
packages: {
'jenkins-api-ts-typings': {
main: './dist/jenkins-api-ts-typings.es6.js',
defaultExtension: 'js'
}
}
In the project’s root folder, after git clone:
npm install
npm run build-pkg
This generates in the /dist
folder:
gitinfo
)
npm run test
Run tests with linting and coverage reporting:
npm run test:prod
This library is based on this excellent TS starter kit, so all commands/scripts described in there are also available for this library.
After installation, just import normally:
import { IJenkinsBuild } from 'jenkins-api-ts-typings';
import { JenkinsBuild } from 'jenkins-api-ts-typings';
For each class, you can feed it the corresponding Jenkins JSON response:
let jsonText = // some JSON string that Jenkins returns
let build: IJenkinsBuild = new JenkinsBuild();
build.fromJsonString(jsonText);
or, more simply, without using JSON.stringify
(since version 0.3.0):
let json = // some JSON
let build: IJenkinsBuild = new JenkinsBuild();
build.fromJson(jsonText);
any
within their containing objects:any
type)fromJsonString(jsonData:string)
on an object, the JSON string parameter value is also kept, and accessible later via getJsonData()
Array<any>
types) are automatically initialized in the class contructors. All value objects (string, number, etc) remain as undefined
until they are set:
let build:IJenkinsBuild = new JenkinsBuild();
build.url === undefined // true
build.name === undefined // true
build.actions === undefined // false
build.actions.length // 0