Create a Tugboat Preview

Arguments

  • repo - Required
    The Tugboat Repository ID for which the preview should be created.

  • preview - Required
    The preview to build. This can be a pull request, branch, tag, commit, or preview ID for the given Repository.

  • type - Optional
    The type of preview to create. Valid values are pullrequest, mergerequest, branch, tag, or commit. If not specified, Tugboat attempts to guess the type by searching for a ref that matches the provided preview name in the following order: pull request number, commit, tag, branch. The first matching ref is used for the preview.

  • label - Optional
    An optional human-readable label, or description, to give to the preview.

  • anchor - Optional
    Whether to tag the resulting preview as an anchored base preview. This only applies if the parent project has the base preview feature enabled. Default: false.

  • base - Optional
    A Preview ID to use as a base for the preview being created. This only applies if the parent project has the base preview feature enabled. If not provided, or the parent project does not have the base preview feature enabled, the preview is created from scratch. This can be a single preview ID, or an array of preview IDs.

Example

socket.on('log', function(data) {
    console.log(data.level, data.message);
});
socket.emit('tugboat', 'previews', 'create', args, callback);

Output

In addition to the final output, "log" events are emmitted as the preview is created. These log events include "level" and "message" fields, and look like the following:

{
    "preview": "58bdc0fd455e930001c14805",
    "level": "info",
    "message": "Preview Log Entry"
}

A successful build will return either an object or an array of objects. It is up to the client to check this before any additional processing. A single object is returned if no base preview, or only one base preview was used. This includes any anchored base previews in the repo. An array of objects is returned when more than one base previews are used.

single

{
    "_id": "58cf4e012057230001ae530a",
    "updatedAt": "2017-03-20T03:35:40.112Z",
    "createdAt": "2017-03-20T03:35:29.073Z",
    "name": "master",
    "repo": "58cf4bfc457b92000138c33d",
    "token": "v0xq1vwswxtr7p3ubxhbfc4j",
    "data": {
        "github": {
            "ref": {
                "name": "master",
                "object": {
                    "url": "https://api.github.com/repos/TugboatQA/tugboat-test/git/commits/e741cf14f476dc3341068a0da022f623b24976b4",
                    "type": "commit",
                    "sha": "e741cf14f476dc3341068a0da022f623b24976b4"
                },
                "url": "https://api.github.com/repos/TugboatQA/tugboat-test/git/refs/heads/master",
                "ref": "refs/heads/master"
            }
        }
    },
    "build_begin": "2017-03-20T03:35:29.620Z",
    "default_service": "58cf4e012057230001ae530b",
    "build_end": "2017-03-20T03:35:39.413Z",
    "size": 418248599,
    "hits": 0,
    "aliases": [],
    "url": [
        "https://master-v0xq1vwswxtr7p3ubxhbfc4j.dev.tugboat.qa",
        "http://master-v0xq1vwswxtr7p3ubxhbfc4j.dev.tugboat.qa"
    ],
    "anchor": false,
    "locked": false,
    "state": "ready",
    "scope": "tugboat",
    "id": "58cf4e012057230001ae530a"
}

array

[
    {
        "_id": "58cf4e012057230001ae530a",
        "updatedAt": "2017-03-20T03:35:40.112Z",
        "createdAt": "2017-03-20T03:35:29.073Z",
        "name": "master",
        "repo": "58cf4bfc457b92000138c33d",
        "token": "v0xq1vwswxtr7p3ubxhbfc4j",
        "data": {
            "github": {
                "ref": {
                    "name": "master",
                    "object": {
                        "url": "https://api.github.com/repos/TugboatQA/tugboat-test/git/commits/e741cf14f476dc3341068a0da022f623b24976b4",
                        "type": "commit",
                        "sha": "e741cf14f476dc3341068a0da022f623b24976b4"
                    },
                    "url": "https://api.github.com/repos/TugboatQA/tugboat-test/git/refs/heads/master",
                    "ref": "refs/heads/master"
                }
            }
        },
        "build_begin": "2017-03-20T03:35:29.620Z",
        "default_service": "58cf4e012057230001ae530b",
        "build_end": "2017-03-20T03:35:39.413Z",
        "size": 418248599,
        "hits": 0,
        "aliases": [],
        "url": [
            "https://master-v0xq1vwswxtr7p3ubxhbfc4j.dev.tugboat.qa",
            "http://master-v0xq1vwswxtr7p3ubxhbfc4j.dev.tugboat.qa"
        ],
        "anchor": false,
        "locked": false,
        "state": "ready",
        "scope": "tugboat",
        "id": "58cf4e012057230001ae530a"
    }
]

Errors

  • 1006: No Repository ID Provided
    The required repo argument was not included in the request.

  • 1015: No Preview ID Provided
    The required preview argument was not included in the request.

  • 1014: No Previews Found
    Returned if the specified previews cannot be created. This may be due to specifying repositories that do not exist, or the requester not having permission to create a preview in the specified repositories.

  • 1021: Repository is Over Quota
    Returned if the repository goes over its quota between preview builds. This ends the preview create, even if there are additional previews to be built in a different repository.

  • 1022: Project is Over Quota
    Returned if a project goes over its quota between preview builds. This ends the preview create, even if there are additional previews to be built in a different repository.

results matching ""

    No results matching ""