Test Automation

Trigger GitLab Tests From Jira Cloud: Set Up On-Demand QA Runs

Trigger GitLab Tests From Jira Cloud: Set Up On-Demand QA Runs

A tester reviewing a Jira issue may need a fresh smoke run without opening GitLab and choosing pipeline parameters. A manually triggered Jira Cloud automation rule can send that request to an existing GitLab test pipeline. GitLab still runs the jobs; Jira supplies the issue context and a controlled way to ask for execution.

The useful outcome of the first request is a traceable pipeline identity. An accepted HTTP request, a successful Jira automation entry, and passing tests are different observations. Design the rule to preserve that distinction before making it available to requesters.

Table of Contents

Confirm the Existing Pipeline and Its Owners

This setup starts with working automated tests in GitLab, not with generating tests or building a new CI configuration. The maintainer should already know which jobs run the intended suite, where they execute, how failures affect job status, and where reports are retained. A pipeline that can also deploy needs particular scrutiny: a Jira request must not accidentally authorize a deployment.

Agree on the responsibilities before configuring the rule:

  • The Jira rule owner controls eligible work items, who can request a run, automation editing access, and nonsecret audit information.
  • The GitLab maintainer approves the project, branch or tag, existing pipeline behavior, runner access, input definitions, and trigger credential handling.
  • The QA reviewer checks that the intended tests completed against the expected build and environment before recording a testing conclusion.

Confirm that the target environment and test data are safe for repeated runs. Treat network reachability from Atlassian, local automation restrictions, runner availability, and protected-ref permissions as prerequisites. Do not loosen those controls to make a request succeed.

The generic pattern uses Jira Cloud automation and GitLab's API. Atlassian's Xray tutorial adds a Test Plan and results reporting into Xray. Those are useful if your team already uses that app, but Xray result storage is not required to request a GitLab pipeline. Jira itself is not executing the tests.

Define a Small Request Contract

Use a fixed destination and a maintainer-approved ref rather than letting the requester supply a repository, URL, branch, environment, or command. Keep the issue key as correlation data, not executable text. A syntactically valid key is also insufficient by itself: the actual Jira work item must satisfy the approved project and type conditions.

Consider this fictional, unexecuted contract, named QA-TRIGGER-CONTRACT-1.0. It assumes an existing test-only branch called qa-on-demand and an existing smoke suite. These names describe an example, not resources created or verified in a real tenant.

  • The destination is one fixed GitLab project approved by its maintainer.
  • The request's ref is always qa-on-demand. It is a top-level API parameter, not a free-text Jira input.
  • The declared string input jira_issue_key contains the triggering issue's key. This example permits QA- followed by a nonzero decimal integer, such as QA-142.
  • The declared string input suite accepts only smoke. Other input names and values are outside this contract.

Use Jira's actual issue context for the key, rather than asking the requester to type another issue's identifier. If additional suites become necessary, review a small allowlist with the maintainer. Do not turn the rule into a general-purpose CI command launcher.

Structured GitLab inputs are distinct from pipeline variables. Inputs have declared types and constraints; variables are not a drop-in substitute with identical validation. A legacy pipeline using variables needs its own reviewed mapping and validation rather than a renamed payload.

Review GitLab's Receiving Configuration

The receiving operation is POST /projects/:id/trigger/pipeline. Its required parameters include a branch or tag ref and a token. For this pattern, the credential is a pipeline trigger token. A personal access token used with another API route, or a CI job token used inside an upstream pipeline, describes a different authentication and execution context.

A trigger token impersonates its owner's project access and permissions. GitLab documents Maintainer or Owner as the prerequisite for creating one. Have the authorized maintainer provision and manage that credential separately; do not ask QA requesters to paste tokens into issues. Review protected-branch or protected-tag permissions for the selected ref. A token does not bypass them.

Check Input Support and Defaults

For a straightforward baseline, use an already approved GitLab installation supporting the trigger API's inputs attribute, generally available since GitLab 18.1. Its earlier history matters on older self-managed installations: the attribute arrived behind a disabled feature flag in 17.10 and was enabled in 17.11. Check the deployed version and configuration rather than assuming that every rolling documentation example is available.

The maintainer should confirm that the main pipeline configuration declares the expected inputs through spec:inputs. Use a string constraint for the issue key and an options list for the suite. Review defaults against other pipeline sources too. Adding mandatory inputs without suitable defaults can break pipelines that start automatically and cannot supply those values interactively.

Validation must continue into the test harness. Passing a string input does not make arbitrary shell interpolation safe. Do not evaluate the issue key, use it as script text, or accept executable content from issue descriptions. The small allowlist and key format should remain data-validation boundaries.

Check Both Pipeline and Job Rules

A pipeline requested with a trigger token uses the source value trigger. The CI job-token multi-project route uses pipeline. Push and merge-request events are different again.

Ask the maintainer to inspect both workflow rules, which can prevent pipeline creation, and job rules, which determine whether the intended test jobs exist in that pipeline. A configuration that works on pushes may reject a trigger-token request or omit its tests. Resolve that deliberately within the existing configuration; do not add a broad catchall merely to obtain a green automation entry.

Build the Jira Cloud Manual Rule

In the applicable Jira Cloud automation scope, create a rule using the documented Manual trigger from work item trigger. Current documentation also uses the term flow. Labels can change, so confirm the corresponding controls in the target tenant before enabling the integration.

  1. Restrict Groups that can run trigger to the approved QA requester group.
  2. Add conditions for the actual project and permitted work-item type before the outbound action.
  3. Keep the GitLab project, destination, ref, and suite under rule-owner control.
  4. Use the triggering issue's key as the correlation value.
  5. Add Send web request only after those eligibility conditions.

The trigger supports Get input from users, but a fixed smoke run needs no free-text ref or command prompt. If the workflow starts from an Xray Test Plan, add the app-specific Test Plan type condition. Do not assume that type exists in Jira core or require Xray when a normal approved QA work item is sufficient.

After the rule is authorized and enabled, an eligible user can access a manual-trigger flow through the work item's Actions menu. Treat the first real invocation as an authorized integration test, not as a harmless preview: sending the POST can create a pipeline and consume runner capacity.

Configure the Outbound Request Without Exposing Secrets

Set the request method to POST and the destination to the fixed project's trigger-pipeline endpoint. Do not include a credential in the URL. Map the token, fixed ref, jira_issue_key input, and suite input according to the receiving API and the body's actual encoding.

GitLab documents a multipart form request using token, ref, and inputs[name] fields. In that representation, this contract's data fields are inputs[jira_issue_key] and inputs[suite]. Jira's Send web request documentation offers a Custom format for your own data. Selecting it does not prove that a hand-written body has become a valid multipart form.

Have the integration owner review the actual encoded body and its matching Content-Type before enabling the rule. A static multipart header without the correctly encoded body and boundary is not a complete request. This procedure supplies a field contract, not a copy-paste payload proven to render in Jira. Do not transplant a Jenkins authentication example or a legacy tutorial body into the GitLab request.

If an approved implementation uses JSON instead, follow the documented API representation and serialize dynamic strings correctly. Jira's asJsonString function produces an escaped, quoted JSON string. It does not validate an issue key, encode multipart fields, or establish that an entire request is correct. Do not wrap an already quoted JSON string in another pair of quotes.

Credential placement is a deployment gate. Atlassian documents hidden values, but that is not proof that every custom-body field has a separate hidden-secret control. Confirm an approved secure method for the trigger token in the actual action and encoding. If that cannot be established, stop the direct setup and have the integration owner evaluate an approved credential-handling service as a separate design.

Keep tokens out of issue text, ordinary variables used for debugging, URLs, exported examples, and audit output. Restrict rule editing to trusted administrators: an editor can change where an outgoing request sends data. Hidden values are also lost when the action or entire flow is duplicated, or when the flow is exported and imported. Review credential handling again after those changes rather than assuming it survived.

Verify the Created Pipeline Before Interpreting Tests

Enable Wait for response so subsequent steps can inspect response data. The current smart-value reference documents webhookResponse.status and webhookResponse.body properties. Confirm the values exposed in your tenant using nonsecret diagnostics before depending on them; do not assume differently named response examples are interchangeable.

Record only the information needed to identify the request and resulting pipeline: issue key, request time, project, returned pipeline ID, ref, commit SHA, source, and initial status. Validate the returned destination before making a pipeline link available. Avoid logging the entire request or response indiscriminately.

Jira's Audit log can show the trigger, conditions, outbound action, and attempted steps. Inspect those details when diagnosing a failure. Even a successful rule run establishes only what Jira processed. A returned pipeline with status created, pending, or running has not demonstrated completed tests.

For later verification, an authorized reader can open that exact pipeline or use GitLab's single-pipeline GET endpoint with separately approved read authentication. Do not assume the trigger token authorizes those reads. Capture the returned commit SHA as well as the ref, because a branch can move. Do not replace the created pipeline with whichever pipeline happens to be latest on that branch.

A QA conclusion needs test evidence. Check that the expected test jobs ran, completed, and produced the intended report for the requested suite. GitLab's JUnit reports do not determine job status by themselves; the test script must exit unsuccessfully when tests fail. A pipeline can therefore look successful while its reporting or failure-propagation contract is wrong. Missing reports, skipped tests, and manually waiting jobs need investigation, not an automatic Pass.

If results are also imported into Xray, verify that separate import and its association with the intended execution. Triggering GitLab, executing individual jobs, and storing results in a test-management app are separate operations. Neither an import acceptance nor a Jira workflow status replaces the relevant test evidence.

Review the Expected Decisions Before a Pilot

Use the following matrix to review the fictional contract before an authorized pilot. These are proposed outcomes, not requests sent, API responses observed, or tests executed. The first row assumes all earlier prerequisites, permissions, project/type checks, and secure request construction have been satisfied.

Proposed Check

Fictional Input or Observation

Expected Decision

Responsible Owner

Approved request

QA-142, qa-on-demand, smoke

Eligible to request a pipeline; no pass recorded

Jira rule owner

Wrong issue project

OPS-142, qa-on-demand, smoke

Reject before sending

Jira rule owner

Unapproved ref

QA-142, personal-branch, smoke

Reject before sending

Jira rule owner

Unsupported suite

QA-142, qa-on-demand, full

Reject before sending

GitLab maintainer

Uncertain delivery

Request timed out; no pipeline identity retained

Reconcile existing pipelines before considering a retry

Integration owner

Missing test evidence

Pipeline reports success; expected report is absent

Keep QA outcome unverified

QA reviewer

For a future pilot, preserve the actual request time, nonsecret correlation data, rule audit entry, created pipeline identity, and final evidence. Keep rejected attempts too. A reviewer should be able to tell whether a request was blocked locally, rejected by GitLab, created a pipeline without the expected jobs, or reached completed test evidence.

Handle Failures Without Blind Retries

GitLab documents a missing ref and rules that block the trigger source as possible causes of a 400 response. A 404 can result from using the wrong token type or the wrong request method. Treat these as diagnostic leads, not exhaustive interpretations of every response. Inspect the actual error without exposing credentials, and involve the appropriate owner rather than widening permissions.

A timeout is more difficult: GitLab may have created the pipeline even though Jira did not retain its response. Repeating the POST can create another run. Have the integration owner reconcile the request against existing pipelines, using available ref, source, commit, time, and correlation evidence. Do not assume that the trigger endpoint supplies an idempotency guarantee or that a matching branch alone identifies the correct attempt.

Document who may authorize another request after reconciliation and how overlapping runs are handled. Keep a new pipeline request distinct from retrying a job in an existing pipeline. Both can consume resources and change the evidence a QA reviewer sees.

Start with one approved test suite and a request path whose owners can explain every handoff. Make it available more broadly only after an authorized pilot demonstrates secure request construction, reliable pipeline identification, and a trustworthy route to the actual test results. Until then, record the integration as unverified rather than converting successful automation into an unsupported testing verdict.

Related

More on Test Automation

Create traceable test cases, prepare release-specific test runs, and keep approved coverage current as the product changes.