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

Installing saucectl

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.

Step 2: Install saucectl

Run the install command from your chosen saucectl home directory in a terminal shell.

Example with npm
npm install -g saucectl

Check the complete list of available installation options.

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 you get a value 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.

(Optional) Step 4: Clone the API Testing Project

If you want to try using existing tests, you can clone the GitHub repository, as shown below.

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

saucectl Commands

Run

Use the run command to execute the tests. The console displays the executing tests, distinguishing which mode is running. The results are available immediately following test completion in your Sauce Labs account.

saucectl run

You can refer to the Command Reference for the complete list of options for the run command and saucectl YAML Configuration for more configuration options.

Vault

Supported saucectl vault commands:

OperationDescription
Get VaultPrint vault's content in JSON format to the stdout.
Get a VariableGet a variable value from a project's vault.
Set a VariableSet/update a variable in a project's vault.
Get a SnippetGet a snippet from a project's vault.
Set a SnippetSet/update a snippet in a project's vault.
List FilesList files stored in the project's vault drive.
Upload a FileUpload a file to a project's vault drive.
Download a FileDownload a file from a project's vault drive.
Delete a FileRemove a file from a project's vault drive.