Builds

NOTE: The Builds endpoint is used for the Classic Wercker stack only. If your application is a Workflows application, you should use the Runs endpoint instead. Attempting to use the Builds endpoint with a Workflows application will result in errors such as "Invalid stack, only stack 1 and 5 are supported for builds."

This page explains how to do the following in Wercker:

Get a build

You can get the details of a single build in order to collect more information about it using:

GET /api/v3/builds/:build

Response

You will receive a respose that looks like:

Status: 200 OK
{
  "status": "finished",
  "startedAt": "2015-04-30T17:06:04.686Z",
  "result": "passed",
  "id": "554260f7dc16db44791955a7",
  "url": "https://app.wercker.com/api/v3/builds/554260f7dc16db44791955a7",
  "application": {
    "stack": 5,
    "privacy": "public",
    "createdAt": "2015-01-28T17:04:09.851Z",
    "owner": {
      "meta": {
        "werckerEmployee": false,
        "username": "wercker"
      },
      "userId": "55310d295732ce8a41000054",
      "avatar": {
        "gravatar": "33a5bfbcf8a2b90f40e849b6f1fa5eeb"
      },
      "name": "wercker",
      "type": "wercker"
    },
    "name": "docs",
    "url": "https://app.wercker.com/api/v3/applications/wercker/docs",
    "id": "54c9168980c7075225004157"
  },
  "branch": "hide_api",
  "createdAt": "2015-04-30T17:05:59.209Z",
  "finishedAt": "2015-04-30T17:09:02.753Z",
  "message": "Hide API header",
  "progress": 100
}

Trigger a new build

You ca also trigger a new build for an application.

This returns a build object.

It is possible to add environment variables, which will be added to the build. The order of the array will be maintained, which makes it possible to use environment variables that were defined earlier. Any environment variables defined as part of the application or deploy target will be overwritten, if using the same key.

POST /api/v3/builds/

JSON payload

Scroll right on the table to reveal cells.
Name Type Description
applicationId String Required The ID of the application for which a build should be triggered.
branch String Optional The Git branch that the build should use. If not specified, the default branch will be used.
commitHash String Optional The Git commit hash that the build should use. Requires branch to be set. If not specified, the latest commit is fetched.
message String Optional The message to use for the build. If not specified, the Git commit message is used.
envVars Array of objects Optional Environment variables that should be added to build. Contains objects with key and value properties.

Response

{
  "id": "557591da3f1aefa778000009",
  "url": "https://app.wercker.com/api/v3/builds/557591da3f1aefa778000009",
  "application": {
    "id": "54c9168980c7075225004157",
    "url": "https://app.wercker.com/api/v3/applications/wercker/docs",
    "name": "docs",
    "owner": {
      "type": "wercker",
      "name": "wercker",
      "avatar": {
        "gravatar": "33a5bfbcf8a2b90f40e849b6f1fa5eeb"
      },
      "userId": "55310d295732ce8a41000054",
      "meta": {
        "username": "wercker",
        "werckerEmployee": false
      }
    },
    "createdAt": "2015-06-08T12:47:39.819Z",
    "privacy": "private",
    "stack": 5
  },
  "branch": "master",
  "createdAt": "2015-06-08T13:00:10.180Z",
  "commitHash": "27625930a8afcaff8e4c3f5370f38e712db7d61e",
  "message": "Fixed OAuth error",
  "progress": null,
  "result": "unknown",
  "status": "notstarted"
}