Introduction to CodeShip API

CodeShip is a cloud-based continuous integration and delivery platform, that allows development teams to automate their software development processes. The CodeShip API provides a RESTful interface for developers, that allows them to programmatically interact with the CodeShip platform.

This article will provide a brief overview of the CodeShip API, and demonstrate some code examples in JavaScript.

Authentication

Before any requests can be made to the CodeShip API, developers are required to authenticate themselves using a personal access token. This token is generated through the CodeShip dashboard, and is required in the Authorization header of all API requests.

const axios = require('axios');

const authToken = 'YOUR_PERSONAL_ACCESS_TOKEN';

axios.defaults.headers.common['Authorization'] = `Bearer ${authToken}`;

With the authorization header in place, requests can be made to CodeShip API endpoints.

Examples

List projects

To list all projects for a given account, use the GET /v2/organizations/{organization_slug}/projects endpoint.

axios.get('https://api.codeship.com/v2/organizations/{organization_slug}/projects')
  .then(response => console.log(response.data))
  .catch(error => console.log(error));

Get a single project

To retrieve details on a single project, use the GET /v2/organizations/{organization_slug}/projects/{uuid} endpoint.

axios.get('https://api.codeship.com/v2/organizations/{organization_slug}/projects/{uuid}')
  .then(response => console.log(response.data))
  .catch(error => console.log(error));

Trigger a build

To trigger a new build for a specific branch in a project, use the POST /v2/organizations/{organization_slug}/projects/{uuid}/builds endpoint.

const postData = {
  build_request: {
    branch: 'MY_BRANCH_NAME'
  }
}

axios.post('https://api.codeship.com/v2/organizations/{organization_slug}/projects/{uuid}/builds', postData)
  .then(response => console.log(response.data))
  .catch(error => console.log(error));

Conclusion

The CodeShip API provides a powerful set of tools for developers to interact with the CodeShip platform. By integrating with the CodeShip API, developers can streamline their development processes, and automate the deployment of new applications and updates. With the use of JavaScript, the API can be easily consumed and integrated within a variety of different applications and development workflows.

Related APIs in Automation