Skip to main content

CI/CD Platform Integration with saucectl

Using the saucectl CLI, you can execute API tests and interact with Sauce Labs API Testing.

What You'll Need

Step 1: Create a Webhook

To utilize saucectl functionalities, you'll need to generate a webhook for your API Testing Project. Once generated, you'll need only the name of your API Testing Project.

To generate a webhook:

  1. Log in to Sauce Labs, then click API Testing.
  2. Navigate to your Project and select the WebHooks tab.
    webhook screenshot
  3. Select Create Hook.
    Create New WebHook
  4. Enter a Hook Name for your webhook (Description is optional), then click Save.
    sample webhook details
  5. The generated Hook URL will then appear. Your Sauce Labs username, Sauce API Testing endpoint, and {hook_id} will populate automatically. For security reasons, you'll need to add your own access key.

Step 2: Install saucectl

In a terminal shell, run the install command from your chosen saucectl home directory.

npm install -g saucectl

saucectl requires access to a valid Sauce Labs account.

Use Environment Variables

saucectl detects your Sauce Labs credentials environment variables and prioritizes them over values in the credentials.yml file when both are present. If you have set them, you may skip this step. Not sure if you have them set? Run the following command to check:

echo $SAUCE_USERNAME
echo $SAUCE_ACCESS_KEY

If a value is returned for both variables, they are set.

  1. Run the configure command:

    saucectl configure
  2. Enter your Sauce Labs Username and Access Key at the prompts.

Step 4: Clone the API Testing Project

git clone https://github.com/saucelabs/saucectl-apitest-example.git

Step 5: Run Tests

Navigate to the root of the API Testing project you just cloned, then use the run command to execute the sample test included with the saucectl example.

cd saucectl-apitest-example
saucectl run

The console displays the executing tests, distinguishing which mode is running.

The results are available immediately following test completion in your Sauce Labs account.

More Information

See saucectl YAML Configuration for more configuration options.