Promise based wrapper for the Codeship V2 API
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.
npm install --save codeship-api
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...",
})();
Populates each organization in codeship.organizations
with it's projects and builds.
await codeship.refresh();
const build = {
organization: '721cea10-b695-0134-5b94-000000000000',
project: '7b3596c0-560e-0135-5b18-000000000000',
build: '20b4a690-6a03-0135-d6ec-000000000000',
};
await codeship.stopBuild(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);