Skip to main content

Sauce Labs with Azure DevOps

Azure DevOps (formerly Visual Studio Team Services or VSTS) is a Microsoft product that provides version control, reporting, requirements management, project management, automated builds, testing and release management capabilities.

What You'll Need

Using Azure DevOps

Follow the instructions below to integrate Sauce Labs testing into your Azure pipeline.

  1. Sign in to your Azure DevOps organization and go to your project.
  2. Go to Pipelines > New pipeline.
  3. Link the new pipeline to your repository (see Azure Pipelines Documentation for guidance). You'll likely need to provide permissions for Azure Pipelines to access your repository management system.
  4. Set your Sauce Labs username and access key as environment variables in your pipeline by clicking Pipeline > Variables, and then pasting the values of your username and access key.
  5. In your source code, you'll need to reference the Sauce Labs environment variables that you set in Azure DevOps. For example:
C# example
var sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME");
var sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY");
  1. Create a YAML file using one of the templates below. You'll also need to reference your Sauce Labs environment variables here.

    - main

    vmImage: ubuntu-latest

    # Multiple pipelines can re-use variables
    # that are stored in a variable group
    - group: sauce-labs-variables

    - task: NodeTool@0
    versionSpec: '14.x'
    displayName: 'Install Node.js'

    - script: |
    # Navigate to the working directory
    cd ./webdriverio/webdriver/examples/w3c/
    # Install node packages
    npm install
    # Run tests on Sauce and enables a high level of logging for CI
    npm run -- --logLevel "debug"

    # Reads the value from 'sauceUsername' in Azure DevOps and
    # stores it into SAUCE_USERNAME env variable
    SAUCE_USERNAME: $(sauceUsername)
    SAUCE_ACCESS_KEY: $(sauceAccessKey)
    displayName: 'install and run WebdriverIO tests in Sauce Labs'

More Information