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
- A Sauce Labs account (Log in or sign up for a free trial license).
- Your Sauce Labs Username and Access Key.
- An existing API Testing Project. For details on how to create one, see API Testing Quickstart.
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:
- Log in to Sauce Labs, then click API Testing.
- Navigate to your Project and select the WebHooks tab.
- Select Create Hook.
- Enter a Hook Name for your webhook (Description is optional), then click Save.
- 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.
npm install -g saucectl
Check the complete list of available installation options.
Step 3: Link Your Sauce Labs Account
saucectl
requires access to a valid Sauce Labs account.
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.
-
Run the
configure
command:saucectl configure
-
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.
- HTTPS
- SSH
git clone https://github.com/saucelabs/saucectl-apitest-example.git
git clone git@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:
Operation | Description |
---|---|
Get Vault | Print vault's content in JSON format to the stdout. |
Get a Variable | Get a variable value from a project's vault. |
Set a Variable | Set/update a variable in a project's vault. |
Get a Snippet | Get a snippet from a project's vault. |
Set a Snippet | Set/update a snippet in a project's vault. |
List Files | List files stored in the project's vault drive. |
Upload a File | Upload a file to a project's vault drive. |
Download a File | Download a file from a project's vault drive. |
Delete a File | Remove a file from a project's vault drive. |