Product documentation
Updated

CI/CD: Run Test Packs from Jenkins

Install the Shift-Left API Jenkins plugin from its .hpi file, add the Run Test Pack build step to a Freestyle job, gate the build on the pass rate, and publish the JUnit results.

Applies to: Professional, Trial and Enterprise editions (the Public API is not part of the free Citizen Developer edition) · Jenkins Freestyle jobs

Overview

The Shift-Left API Jenkins plugin adds a build step, Shift-Left API Automation Integration: Run Test Pack, to Freestyle jobs. The step signs in to your Shift-Left API server, starts one of your test run packs, waits for that run to finish, applies a quality gate, and can write JUnit XML and a JSON summary into the workspace. If the gate fails, the build is marked FAILURE (or UNSTABLE, if you choose).

The plugin applies the same gate rules as the GitHub Action and the Azure DevOps task.

Note: The plugin is not in the Jenkins Update Center, so you will not find it by searching under Available plugins. You install it from its .hpi file, as below.

Before you begin

  1. A test run pack with its environment chosen in the pack. See Test Run Pack Wizard.
  2. The Public API switched on, with the CI user's role in Allowed Roles, under Settings → Integrations → Public API. See Public API.
  3. A CI user (email and password), saved in Jenkins as a Username with password credential.
  4. A server the Jenkins agent can reach. The pack itself runs on your Shift-Left API server.

Step 1 — Install the plugin

  1. Download the .hpi from the jenkins release in Total-Shift-Left/Shift-Left-API-Integrations. You can also build it from the plugin source with mvn -B -ntp verify; the file lands in target/.
  2. In Jenkins, go to Manage Jenkins → Plugins and open Advanced settings.
  3. Under Deploy Plugin, click Choose File, select the .hpi, then Deploy.
  4. Restart Jenkins when prompted, and check that Shift-Left API Automation Integration is listed under Installed plugins.

Step 2 — Add the build step

In a Freestyle job, add the build step Shift-Left API Automation Integration: Run Test Pack and fill in its sections:

SectionFieldWhat to enter
Shift-Left API connectionServer URLYour server's base URL, with no trailing slash.
Tenant IDLeave empty unless your installation is multi-tenant.
CredentialsThe CI user's credential. Click Test Connection to check sign-in and reachability.
Test PackPack IDPick the pack from the list, which fills after a successful connection.
ExecutionWait for completionLeave on to wait for the run and grade it.
Poll interval (seconds)Default 10.
Overall timeout (minutes)Default 60.
Quality GatePass threshold (%)Minimum pass rate. 0 turns the threshold off.
Fail build when any ERROR testsFail when any test ends in ERROR, whatever the pass rate.
Build result on gate failureFAILURE blocks the build; UNSTABLE warns.
ArtifactsWrite JSON summaryOptional. A workspace-relative path for the summary.
Write JUnit XMLOptional. A workspace-relative path for the JUnit file.

Step 3 — Publish the results

If you write JUnit XML, add the post-build action Publish JUnit test result report and point it at the same path, so each test shows on the build's Test Result page. After a build, the Shift-Left API Automation Integration link in the build's sidebar shows the run summary and links to the files.

Declarative pipelines (Jenkinsfile)

The plugin provides a Freestyle build step only. In a Jenkinsfile, call the REST API from a shell step instead. Any CI via the REST API has a script you can save as ci/run-shiftleft-pack.sh and call like this:

// Jenkinsfile
pipeline {
  agent any
  environment {
    SHIFTLEFT_URL          = 'https://shiftleft.yourcompany.com'
    SHIFTLEFT_TEST_PACK_ID = 'your_pack_id'
  }
  stages {
    stage('API Tests') {
      steps {
        withCredentials([usernamePassword(credentialsId: 'shiftleft-api',
                         usernameVariable: 'SHIFTLEFT_EMAIL', passwordVariable: 'SHIFTLEFT_PASSWORD')]) {
          sh 'bash ci/run-shiftleft-pack.sh'
        }
      }
    }
  }
}

Generate a ready-made pipeline file

You do not have to write the Jenkins file by hand. Open a test pack, choose Run in your pipeline, pick Jenkins, and Shift-Left API generates the file for you. There is no token field, so nothing you type is pasted into the file unchecked. The file runs the pack with the Shift-Left test runner and can add:

  • The release verdict gate. Tick Also ask whether the project is ready to release, and fail the build if it is not. See Release verdict.
  • Only the tests behind some tickets. The runner flag --tickets PROJ-21,PROJ-22 --environment staging runs just those tests. A ticket with no tests fails the build, because no evidence is not a pass. Add --tickets-allow-untested to switch that off. This needs requirements imported from a tracker; see Requirements from trackers.
  • Security and policy options such as --sarif, --fail-on-severity and --policy.

For the runner, use the runner file in your repository, or type an https address together with your own SHA-256 checksum. If the checksum does not match, or the download fails, the build stops before the runner starts. Generated files need the Professional, Trial or Enterprise edition. The verdict answer can be kept as a record, but Jenkins posts no pull-request comment; GitHub, GitLab and Azure DevOps do.

Good to know

  • The environment comes from the pack. Keep one pack per environment and choose the pack per job or branch.
  • One run per pack at a time. A second start of a running pack is refused (HTTP 409).
  • It grades the run it started, not the pack's previous run.
  • CI sign-ins and CI-started runs are recorded in the audit log.

Next steps

Still stuck?

Tell us what you’re trying to accomplish and we’ll point you to the right setup—installation, auth, or CI/CD wiring.