The ideal time to automatically run API and web app tests is after a deployment. Using the Assertible deployments API, you can run all tests for a web service as part of your continuous-integration pipeline.


Deployments API Diagram

There are two ways to create a deployment:

  1. Command-line or build script
  2. Integrations

Command-Line

The easiest way to create a deployment is to run a simple curl command:

ACCESS_TOKEN=ASSERTIBLE_DEPLOY_TOKEN
ENVIRONMENT=production
VERSION=`git log -n 1 --pretty=format:"%H"`
SERVICE=ASSERTIBLE_SERVICE_ID

curl -u $ACCESS_TOKEN: -XPOST 'https://assertible.com/deployments -d'{
    "service" : "'"${SERVICE}"'",
    "environmentName" : "'"${ENVIRONMENT}"'",
    "version" : "'"${VERSION}"'"
}'

This script can easily be adapted to CI environments and test automation systems. See the examples for more examples.

Parameters

These parameters can also be used in a request toPOST /deployments:

  • api

    The web service (API) id.

  • version

    A textual representation of the application version.

  • environmentName optional

    The environment name. Defaults to production when no environmentName parameter is specified. See our environments documentation for more information.

  • ref optional

    A source control reference.

  • url optional

    An external url for viewing the deployment.

If the POST request is made twice, the deployment is updated. This only has an impact for "optional" parameters like ref or url. A unique deployment is represented by the service, environment name, and version combination.

Integrations

Deployments can also be created from integrations. The only supported deployment integration is GitHub.

GitHub

The GitHub deployments integration executes tests when a deployment event is receieved from GitHub for a repository.

Deployments API examples

Successful request

If the request succeeds, it will respond with the unique id of the deployment:

curl -XPOST 'https://assertible.com/deployments -d'{
    "service" : "123e4567-e89b-12d3-a456-426655440000",
    "environmentName" : "production",
    "version" : "v1.2"
}'
{"id":"caacafdc-8ddc-4245-a0f4-f6715c5d9478"}

Failed request

If creating the deployment fails, an error will be returned:

curl -XPOST 'https://assertible.com/deployments -d'{
    "service" : "123e4567-e89b-12d3-a456-426655440000",
    "environmentName" : "staging",
    "version" : "v1.2"
}'
{"code":"InvalidRequestError","message":"Cannot parse request body\n\"Error in $: key \\\"service\\\" not present\"\n"}

Automate your QA pipeline

Define and test your web service with Assertible Track and test API deployments across environments Schedule API monitoring and failure alerts

Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.

Sign up for free