---
title: "[Xray Server] Triggering automation from Xray"
canonical: "https://docs.getxray.app/space/ProductKB/46269093/%5BXray%20Server%5D%20Triggering%20automation%20from%20Xray"
format: markdown
---
<span style="color: #000000">Sometimes, it may be useful to trigger CI jobs directly from Jira and see the results in the test management tool (i.e. Xray).</span>

<span style="color: #000000">Currently (as of v3.6), this is not possible out-of-the-box yet. However, with some minor customization, this can already be achieved as depicted in</span><span style="color: #000000"> </span>[these ScriptRunner-related instructions](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraJenkinsprojectbuildfromaTestPlan)<span style="color: #000000">.</span>

<span style="color: #000000">Depending on the use case, this may be quite simple or a little more complex to implement.</span>

# <span style="color: #000000">Requirements</span>

<span style="color: #000000">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.</span>

<span style="color: #000000">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 ScriptRunner even though it requires coding skills.</span>


<span style="color: #000000">Possible (tested) apps include:</span>

- [<span style="color: #000000">Jenkins Integration for Jira</span>](https://marketplace.atlassian.com/apps/1211376/jenkins-integration-for-jira?hosting=server&tab=overview)<span style="color: #000000">  (simpler)</span>
- [<span style="color: #000000">Automation for Jira</span>](https://marketplace.atlassian.com/apps/1215460/automation-for-jira?hosting=server&tab=overview)<span style="color: #000000"> (has a broader scope than "Jenkins integration for Jira" app but may be used to implement some simple scenarios)</span>
- [<span style="color: #000000">ScriptRunner</span>](https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=server&tab=overview)<span style="color: #000000"> </span><span style="color: #000000">(useful, especially if you already have it, and more flexible; more complex though)</span>

<span style="color: #000000">Other (</span><u><span style="color: #000000">untested</span></u><span style="color: #000000">) apps include:</span>

- [<span style="color: #000000">PowerScripts</span>](https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=server&tab=overview)

<span style="color: #000000">Ultimately, advanced users may prefer to implement a very simple Jira app for this.</span>

# <span style="color: #000000">Use Cases</span>

## <span style="color: #000000">Trigger a CI job blindly</span>

<span style="color: #000000">In this scenario, we're assuming that:</span>

- <span style="color: #000000">you just want to trigger a CI job, period; this job may be totally unrelated to the issue from where you triggered it</span>
- what the CI job will do, including if it will report the results back to Xray or not, is not relevant




<span style="color: #000000">For most CI tools, this only requires that you perform some HTTP request passing the CI job as an argument, somehow.</span>

"Jenkins integration for Jira", "Automation for Jira", "ScriptRunner" apps can be used to implement this scenario.

## <span style="color: #000000">Examples</span>

- <span style="color: #172b4d">Automation for Jira</span>
  - [<span style="color: #172b4d">Trigger a Jenkins project build from an issue</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY730/Integration+with+Automation+for+Jira#IntegrationwithAutomationforJira-TriggeraJenkinsprojectbuildfromanissue)
- <span style="color: #172b4d">Jenkins Integration for Jira</span>
  - <span style="color: #172b4d">configure your Jenkins "site" (server) in the app setting</span>
  - trigger the Jenkins "build"
- <span style="color: #172b4d">ScriptRunner (these examples also report the results back to the current issue)</span>
  - [<span style="color: #172b4d">Trigger a Jenkins project build from a Test Plan</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraJenkinsprojectbuildfromaTestPlan)
  - [<span style="color: #172b4d">Trigger a Bamboo plan build from a Test Plan</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraBambooplanbuildfromaTestPlan)

## <span style="color: #000000">Trigger a CI job and report back to the current issue</span>

<span style="color: #000000">In this scenario, we're assuming that:</span>

- <span style="color: #000000">you want to trigger a CI job and report back the results to the current issue (e.g. Test Plan)</span>
- <span style="color: #000000">the tests that will run are</span><span style="color: #000000"> </span><u><span style="color: #000000">unrelated</span></u><span style="color: #000000"> </span><span style="color: #000000">with the caller issue; it's up to the logic built into the CI job to decide which tests to run</span>


![image](media://7742a5b2-b17c-4d0e-85c2-213c12f93207)


<span style="color: #000000">"Jenkins Integration for Jira", "Automation for Jira", "ScriptRunner" apps can be used to implement this scenario.</span>

## <span style="color: #000000">Examples</span>

- <span style="color: #000000">Jenkins Integration for Jira</span>
  - <span style="color: #000000">in this case, you would need to use pipeline-based Jenkins projects where you would use a snippet of code to obtain the calling Jira issue which could be used later on in the step for uploading the results to Xray; you may need to enable the usage of these classes in Jenkins settings</span>
    - *<span style="color: #000000">def sourceIssueKey = currentBuild.getRawBuild().getCause(org.marvelution.jji.trigger.JiraCause).getIssueKey()</span>*
      - <span style="color: #172b4d">configure your Jenkins "site" (server) in the app setting</span>
      - trigger the Jenkins "build"
- <span style="color: #172b4d">Automation for Jira</span>
  - [<span style="color: #172b4d">Trigger a Jenkins project build from a Test Plan and report the results back to it</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY730/Integration+with+Automation+for+Jira#IntegrationwithAutomationforJira-TriggeraJenkinsprojectbuildfromaTestPlanandreporttheresultsbacktoit)
- <span style="color: #172b4d">ScriptRunner</span>
  - [<span style="color: #172b4d">Trigger a Jenkins project build from a Test Plan</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraJenkinsprojectbuildfromaTestPlan)
  - [<span style="color: #172b4d">Trigger a Bamboo plan build from a Test Plan</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraBambooplanbuildfromaTestPlan)

## <span style="color: #000000">Trigger a CI job for the selected tests and report back to the current issue</span>


<span style="color: #000000">In this scenario, we're assuming that:</span>

- <span style="color: #000000">you want to trigger a CI job and report back the results to the current, caller issue (e.g. Test Plan, Test Execution)</span>
- <span style="color: #000000">the tests that you want to run are the automated ones present in the caller issue (e.g. Test Plan, Test Execution)</span>


![image](media://25676e2e-18f0-4bd9-b20d-1088a0420193)


<span style="color: #000000">This scenario, though feasible, is a bit more complex for two reasons:</span>


1. <span style="color: #000000">because you'll need to pass the information about the tests that you run to the CI tool</span>
2. <span style="color: #000000">the CI job needs to process the previous information and somehow orchestrate test runner; this is highly dependent on the automation framework</span>


<span style="color: #000000">"ScriptRunner" app can be used to implement this scenario.</span>

## <span style="color: #000000">Examples</span>

- <span style="color: #172b4d">ScriptRunner</span>
  - [<span style="color: #172b4d">Trigger a Jenkins project build from a Test Plan, for the Tests contained in the Test Plan</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraJenkinsprojectbuildfromaTestPlan,fortheTestscontainedintheTestPlan)
  - [<span style="color: #172b4d">Trigger a Bamboo plan/stage build from a Test Plan, for the Tests contained in the Test Plan</span>](https://getxraydocs.atlassian.net/wiki/display/XRAY360/Extending+and+integrating+with+Xray+using+ScriptRunner#ExtendingandintegratingwithXrayusingScriptRunner-TriggeraBambooplan/stagebuildfromaTestPlan,fortheTestscontainedintheTestPlan)

# <span style="color: #000000">References</span>

- [<span style="color: #000000">https://docs.automationforjira.com/</span>](https://docs.automationforjira.com/)
- [<span style="color: #000000">https://docs.automationforjira.com/reference/smart-values.html</span>](https://docs.automationforjira.com/reference/smart-values.html)