Configure environment variables in Azure DevOps

Learn how to configure environment variables in Azure DevOps, so you and your team can upload apps and run automation tests.

Before you start

Create service connections

In Azure DevOps, open your project, then select Settings.

In the Pipelines pane, select Service connections, then Create a service connection.

Search for Kobiton, then create a connection for Kobiton API and Kobiton Server Executor.

Kobiton API

We recommend creating a shared Kobiton account for running automation tests instead of using your personal Kobiton API credentials.

Enter the username and password for the shared Kobiton account, then select Verify and save.

Kobiton Executor Server

Enter the username and password for the executor server credentials you were sent, then select Verify and save.

Update your test suite

In the terminal, open your project.

Example
cd ~/my-project

Open your test suite’s configuration file in a text editor.

Example
nano ./src/test/Config.java

Add empty environment variables to the file using the following table. You’ll assign values later when you add Kobiton Automation Test Executor or Kobiton App Version Uploader to your pipeline.

Environment Variable Required Description

KOBITON_USERNAME

Yes

Your Kobiton username.

KOBITON_API_KEY

Yes

Your Kobiton API key.

KOBITON_SESSION_APPLICATION

No

Your app’s Kobiton App ID.

KOBITON_DEVICE_NAME

No

A device’s name in Kobiton.

KOBITON_SESSION_PLATFORM_VERSION

No

A device’s platform version.

KOBITON_DEVICE_PLATFORM_NAME

No

A device’s platform version, either Android or iOS.

Example
public class Config {
    enum SERVER_TYPE_ENUMS {KOBITON, LOCAL}

    private String kobitonServerUrl = "https://" + System.getenv("KOBITON_USERNAME") + ":" + System.getenv("KOBITON_API_KEY") + "@api.kobiton.com/wd/hub";

    public void setCapabilities() {
        capabilities.setCapability("deviceGroup", "KOBITON");
        capabilities.setCapability("deviceName", System.getenv("KOBITON_DEVICE_NAME"));
        capabilities.setCapability("platformName", System.getenv("KOBITON_DEVICE_PLATFORM_NAME"));
        capabilities.setCapability("platformVersion", System.getenv("KOBITON_SESSION_PLATFORM_VERSION"));
        capabilities.setCapability("app", System.getenv("KOBITON_SESSION_APPLICATION"));
    }

    public static final SERVER_TYPE_ENUMS SERVER_TYPE = SERVER_TYPE_ENUMS.KOBITON;
    public static final int IMPLICIT_WAIT_IN_SECOND = 30;
    public static final int DEVICE_WAITING_MAX_TRY_TIMES = 5;
    public static final int DEVICE_WAITING_INTERVAL_IN_MS = 30000;
}

When you’re finished, save your changes.