TestKase
TestKase
|Docs
Organization & AccountIntegrationsCI/CD

Jenkins

Run Automate from a Jenkins pipeline with the access key in Jenkins credentials.

Store the access key

  1. Manage Jenkins → Credentials → (global) → Add Credentials.
  2. Kind Secret text, Secret = your TestKase access key, ID testkase-access-key. Save.

Add the job

Save this as Jenkinsfile in your repository, replacing [email protected] with your TestKase username:

One-time setup: run this locally and commit the result, before the pipeline needs it.

npm install --save-dev @testkase/playwright-reporter

The CI job only installs what's already committed — it can't add packages on its own. Skip this and the job either fails (no internet access) or runs slow (fetches the package fresh every time).

pipeline {
  agent any
  environment {
    TK_USERNAME    = '[email protected]'
    ACCESS_KEY     = credentials('testkase-access-key')   // Secret text credential
    TESTKASE_BUILD = "ci-${BUILD_NUMBER}"
  }
  stages {
    stage('E2E on TestKase') {
      steps {
        sh 'npm ci'
        sh 'npx testkase-playwright test'
      }
    }
  }
}
pipeline {
  agent any
  environment {
    TK_USERNAME    = '[email protected]'
    ACCESS_KEY     = credentials('testkase-access-key')   // Secret text credential
    TESTKASE_BUILD = "ci-${BUILD_NUMBER}"
  }
  stages {
    stage('E2E on TestKase') {
      steps {
        sh 'npm ci'
        sh 'npm test'   // your Selenium suite — see the note below
      }
    }
  }
}
pipeline {
  agent any
  environment {
    TK_USERNAME    = '[email protected]'
    ACCESS_KEY     = credentials('testkase-access-key')   // Secret text credential
    TESTKASE_BUILD = "ci-${BUILD_NUMBER}"
  }
  stages {
    stage('E2E on TestKase') {
      steps {
        sh 'npm ci'
        sh 'npm test'   // your Appium suite — see the note below
      }
    }
  }
}

Playwright runs through the testkase-playwright wrapper, which reads these environment variables for you. Selenium and Appium have no wrapper — your existing test code builds the Hub URL from TK_USERNAME / ACCESS_KEY itself, exactly as it already does outside CI. See Selenium: point your suite at TestKase and Appium: getting started.

What to check

Build nameci-${BUILD_NUMBER} — sessions group under it on the Automate dashboard
Secretread from credentials('testkase-access-key') into ACCESS_KEY; never in the repository
Tunneladd npx testkase-tunnel --token "$ACCESS_KEY" & before the test step if the tests open a URL the farm can't reach
Jenkins masks any value bound with credentials() in the console log automatically.

Windows agents

The Jenkinsfile above uses sh, a Linux/macOS shell step, so a Windows agent — the machine that runs the job, not necessarily the machine hosting Jenkins — hits one of two failures. Both are one-time fixes, per agent.

▶The job fails with "sh not found"

Pick one.

Option A — add Git's shell to the PATH. Git for Windows ships sh.exe. Point the machine at it and the Jenkinsfile above needs no changes.

Manage Jenkins → System → Shell executable doesn't apply here. That setting is for Freestyle jobs only. This Jenkinsfile is a Pipeline job, and a Pipeline sh step looks for sh.exe on the machine-wide PATH — nowhere else.

  1. Install Git for Windows on the agent, if it isn't there already.

  2. Open PowerShell as Administrator and run:

    $path = [Environment]::GetEnvironmentVariable('Path', 'Machine')
    [Environment]::SetEnvironmentVariable('Path', "$path;C:\Program Files\Git\usr\bin", 'Machine')
    Restart-Service Jenkins
    Start-Sleep 5
    (Get-Service Jenkins).Status
  3. Wait about a minute, then click Build Now.

Option B — use bat instead of sh. No install, no restart, but every step changes:

pipeline {
  agent any
  environment {
    TK_USERNAME    = '[email protected]'
    ACCESS_KEY     = credentials('testkase-access-key')
    TESTKASE_BUILD = "ci-${BUILD_NUMBER}"
  }
  stages {
    stage('E2E on TestKase') {
      steps {
        bat 'npm ci'
        bat 'npx testkase-playwright test'
      }
    }
  }
}
▶The job fails with "npm is not recognized" even after fixing sh

Jenkins usually runs as a Windows service under LocalSystem, not as you. It only sees the machine-wide PATH — never your own. That's why npm works in your terminal but the job still fails.

Check whether Node is on the machine-wide PATH:

$path = [Environment]::GetEnvironmentVariable('Path', 'Machine')
$path -split ';' | Select-String -Pattern node

Prints a path, for example C:\Program Files\nodejs\ — Node is already visible to the service; look elsewhere for the failure.

Prints nothing — Node is on your user PATH only, or not installed. Find its folder (run Get-Command node in a terminal where node already works, or check C:\Program Files\nodejs), then add it the same way as the sh fix:

$path = [Environment]::GetEnvironmentVariable('Path', 'Machine')
[Environment]::SetEnvironmentVariable('Path', "$path;C:\Program Files\nodejs", 'Machine')
Restart-Service Jenkins

If Node isn't on the agent at all, install it as administrator — the official installer writes to the machine PATH by default — then restart the service the same way.

Run the pipeline once. Within a few seconds the session appears on Automate → Sessions; the job goes red if any test fails.