Sometimes, it may be useful to trigger CI jobs directly from Jira and see the results in the test management tool (i.e. Xray).

Currently (as of August 2020), this is not provided directly by Xray yet. However, with some minor customization, this can easily be achieved.

Depending on the use case, this may be quite simple or a little more complex to implement.

Requirements

In order to implement triggering from Xray, and while it is not built-in, you'll need to either use Jira Cloud automation capabilities or use an additional Jira app/plugin for that. If using an external app, it must provide some sort of Jira customization, giving you the ability to add an action (e.g. button) on the UI; besides that, it shall also provide a way of implementing the corresponding code/action that will invoke the CI tool.

Which app to use depends on your context (e.g. existing apps installed in your Jira instance) and the exact use case you aim to implement; depending on that, simpler apps may be used; as a last resource, you may use Power Scripts or ScriptRunner even though it requires coding skills.


Please note

As Jira Cloud now includes automation capabilities (i.e. with the recent acquisition of Automation for Jira app), this may be the most straightforward approach to trigger (manually or automatically) builds in the CI/CD tool.



Possible (tested) solutions include:

Other (untested) apps include:

Use Cases

Trigger a CI job blindly

In this scenario, we're assuming that:

  • you just want to trigger a CI job, period; this job may be totally unrelated to the issue from where you triggered it
  • what the CI job will do, including if it will report the results back to Xray or not, is not relevant




For most CI tools, this only requires that you perform some HTTP request passing the CI job as an argument, somehow.

Examples

Trigger a CI job and report back to the current issue

In this scenario, we're assuming that:

  • you want to trigger a CI job and report back the results to the current issue (e.g. Test Plan)
  • the tests that will run are unrelated with the caller issue; it's up to the logic built into the CI job to decide which tests to run


Examples

Trigger a CI job for the selected tests and report back to the current issue

In this scenario, we're assuming that:

  • you want to trigger a CI job and report back the results to the current, caller issue (e.g. Test Plan, Test Execution)
  • the tests that you want to run are the automated ones present in the caller issue (e.g. Test Plan, Test Execution)



This scenario is a bit more complex for two reasons:

  1. because you'll need to pass the information about the tests that you run to the CI tool
  2. the CI job needs to process the previous information and somehow orchestrate test runner; this is highly dependent on the automation framework

There is no straightforward approach to implement this.

References