codeship-api

Node.js wrapper for Codeship

Usage no npm install needed!

<script type="module">
  import codeshipApi from 'https://cdn.skypack.dev/codeship-api';
</script>

README

Codeship API

Build Status Coverage Status

Promise based wrapper for the Codeship V2 API

V2 API - Required Access

V2 of the Codeship API requires a dedicated codeship.com account to access; this restricts the use of

  • Third party authentication services - Github, Gitlab, Bitbucket etc
  • Accounts with 2FA

For each project where access is required the project must be in a respective Team for that project. For further information refer to the Codeship documentation.

Install

npm install --save codeship-api

Usage

Authenticate

Authenticates against the Codeship API populating the class with the organizations, token and expiry. Reauthentication is automatic upon refreshing.

const Codeship = require('codeship');

(async () => {
  const codeship = new Codeship({ username: 'test', password: 'test' });
  await codeship.authenticate();

  console.log(codeship);
  // "expiry": 1504275032,
  // "organizations": {
  //   "Codeship": {
  //     "scopes": [
  //       "build.read",
  //       "project.read",
  //     ],
  //     "uuid": "dc37c39f-731e-4100-b8bf-69dae9eb14aa",
  //   },
  //   "Codeship Test Org": {
  //     "scopes": [
  //       "build.read",
  //       "build.write",
  //       "project.read",
  //       "project.write",
  //     ],
  //     "uuid": "dc37c39f-731e-4100-b8bf-69dae9eb14ab",
  //   },
  // },
  // "token": "eyJ0eXAi...",
})();

Refresh

Populates each organization in codeship.organizations with it's projects and builds.

await codeship.refresh();

Stop Build

const build = {
    organization: '721cea10-b695-0134-5b94-000000000000',
    project: '7b3596c0-560e-0135-5b18-000000000000',
    build: '20b4a690-6a03-0135-d6ec-000000000000',
  };

await codeship.stopBuild(build);

Restart Build

const build = {
    organization: '721cea10-b695-0134-5b94-000000000000',
    project: '7b3596c0-560e-0135-5b18-000000000000',
    build: '20b4a690-6a03-0135-d6ec-000000000000',
  };

await codeship.restartBuild(build);