Skip to main content

Integrate with CI/CD Platforms

Requirements#

APIF-CTL#

The API Fortress Mark3 cloud CLI tool (apifctl) allows you to execute tests and interact with API Fortress either locally, or in a pipeline by using the following docker image: quay.io/saucelabs/apifctl.

To use most of the tool's functionalities, a webhook is required for the project (just like with the old CLI tool: apif-auto). You can either create or retrieve a webhook from the dashboard. Visit the webhooks section for further details.

The webhooks are organized in the following manner:

  • username: your Sauce Labs user name

  • access_key: your Sauce Labs access key

  • hookId: generated by API Fortress Mark3 cloud

    https://<username>:<access_key>@domain/api-testing/rest/v4/<hookId>

To run the CLI tool:

docker run quay.io/saucelabs/apifctl

Generating a Webhook#

To create a webhook:

  1. Navigate to the project window and select the WebHooks tab.

    webhook screenshot
  2. Select Create Hook.

    Create New WebHook
  3. Enter the field details and select Save.

    sample webhook details
  4. A generated Hook URL will appear. Copy it to your clipboard and use it either locally or as part of CI build (the URL also appears in the user settings section).

    sample Hook URL

Commands#

run#

Description: Runs a single test. Both hookId and testId are required. The testId is typically located in the URL when viewing the test through the API Testing UI, e.g. /api-testing/project/<projectId>/test/<testId>/.
Example:

docker run quay.io/saucelabs/apifctl run -H \https://<username>:<accessKey>@api.us-west-1.saucelabs.com/api-testing/rest/v4/<hookId> \-i <testId>

run-all#

Description: Runs all the complete tests in the project referenced by the hook.
Example:

docker run quay.io/saucelabs/apifctl run-all -H \https://<username>:<accessKey>@api.us-west-1.saucelabs.com/api-testing/rest/v4/<hookId>

run-tag#

Description: Runs all the tests tagged with a specific tag.
Example:

docker run quay.io/saucelabs/apifctl run-tag -H \https://<username>:<accessKey>@api.us-west-1.saucelabs.com/api-testing/rest/v4/<hookId> \-tag production

exec#

Description: Sends a test residing in the local file system (directory with unit.xml and input.xml) to the cloud for execution.
Example:

docker run -v $(pwd)/tests:/tests quay.io/saucelabs/apifctl exec -H \https://<username>:<accessKey>@api.us-west-1.saucelabs.com/api-testing/rest/v4/<hookId> \-p /tests/test_abc

upload#

Description: Uploads a test residing in the local file system (directory with unit.xml and input.xml) to the cloud for storage.
Example:

docker run -v $(pwd)/tests:/tests quay.io/saucelabs/apifctl upload -H \https://<username>:<accessKey>@api.us-west-1.saucelabs.com/api-testing/rest/v4/<hookId> \-p /tests/test_abc

Command Options#

-E#

Description: Sets environment variables with your command.
Example:

-E domain=staging.com,id=123

-f#

Description: Sets the data format: json || junit.
Example:

-f junit

-t#

Description: Adds a set of tags to the resulting event.
Example:

-t production,smoketest