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 possible out-of-the-box yet. However, with some minor customization, this can be already 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 use an additional Jira app/plugin for that. This app 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
Possible (tested) solutions include:
- using the built-in automation capabilities of Jira Cloud, formerly also known as "Automation for Jira" app (has a broader scope than "Jenkins integration for Jira" app but may be used to implement some simple scenarios)
Other (untested) apps include:
- Jenkins Integration for Jira (simpler and focused on Jenkins, seems to work)
- PowerScripts
- ScriptRunner (more complex though)
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
- Automation for Jira
- Trigger a Jenkins project build from an issue
- Trigger a Bitbucket pipeline from an issue
- enkins Integration for Jira
- ScriptRunner (these examples also report the results back to the current issue)
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
- Automation for Jira
- ScriptRunner
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:
- because you'll need to pass the information about the tests that you run to the CI tool
- 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 this.