Please note
The following scripts and instructions are provided as-is, no warranties attached; use with care.
Please feel free to adapt them to your needs.
Note: We don't provide support for these apps; if you have doubts concerning its usage, please contact Cprime support.
Overview
Cprime provides a set of Jira apps that allow the implementation of powerful custom automation rules, including Power Scripts, Power Custom Fields for Jira, and Power Actions for Jira.
All of those come with the SIL (Simple Issue Language) engine that provides an abstraction layer over the internal of Atlassian APIs, allowing you to easily implement and maintain Jira automation-related scripts.
Power Scripts | Power Custom Fields for Jira | Power Actions for Jira | |
---|---|---|---|
used to... | implement automation rules | implement custom fields whose values are derived from custom logic | implement buttons/UI elements, having a custom logic |
triggering |
|
| N/A |
Use cases
Create a Test Set, Test Execution or a Test Plan programmatically
This use case requires the Power Scripts Fields app.
Sometimes you may need to create a Test Set, a Test Execution, or a Test Plan programmatically.
The following example shows how to create a Test Execution; it can easily be adapted for other Xray issue types. You'll need to update the corresponding REST API endpoint for adding the tests to that entity.
Please check SIL's documentation for more info on createissue() and on httpPost().
Validate requirement before allowing to make a transition
This use case requires the Power Scripts Fields app.
Sometimes you may need to assure that the requirement is actually OK before transitioning it to some status, or before resolving it.
The following script validates the requirement based on the tests executed for the version assigned to the requirement issue.
You can either make the validation based on the existence of failed tests (i.e. requirement status is "NOK") or, in a more complete way by making sure all of them are passing (i.e. requirement status is "OK").
Reopen/transition linked Tests to a requirement/user story
This use case requires the Power Scripts Fields app.
Whenever you change the specification of a requirement/user story, you most probably will need to review the Tests that you have already specified.
The following script tries to make a transition on all linked Tests to a requirement. You can hook it to a post-function on some transition of the requirement/user story.
Please check SIL's documentation for more info on autotransition().
Trigger CI/CD builds
The following examples show how you can implement some actions, using Power Actions, to trigger a build/job in a CI/CD tool such as Jenkins, Bamboo, or others.
There are some come common steps:
- define some global variables, if you want, to have the details about the CI/CD tool; this can be done using SIL Manager by creating a properties file named
sil.properties
- create a Power Actions Custom Field
- You can configure it to just be available for some issue types (e.g. Test Plan)
- Configure the button/s and its/their logic (i.e. Condition, Screen, and Action scripts). You may create one or more buttons.
- For more info on the related scripts, please see the instructions ahead.
Trigger Jenkins job and report back to Test Plan
In this case, we're going to give users the ability to trigger an existing job/project in Jenkins.
We'll obtain the list of available jobs/projects using Jenkins REST API which we'll present to the user. Then, we trigger the build after the user confirms some options.
Jenkins configuration
In Jenkins, we need to generate an API token for some user, which can be done from the profile settings page.
At the project level, we need to enable remote build triggers, so we can obtain an "authentication token" to be used in the HTTP request afterwards.
The project itself is a normal one; the only thing relevant to mention is that this project is a parameterized one, so it receives a TESTPLAN variable, that in our case will be coming from Jira.
The final task submits the results linking the Test Execution to the Test Plan passed as an argument.
Power Actions configuration
We need to configure the Power Action custom field created earlier, namely the Condition, Screen, and Action Scripts; this from the custom field configuration as follows.
A new button will be available on the custom field. You'll need to add it to the view issue screen.
From the "job" dropdown you can select the job you want to run. You can also specify whether you want to report the results back to the current Test Plan and if you want to set that job as the default one for that Test Plan (so it pre-selected the next time you invoke it).
Trigger Bamboo plan and report back to Test Plan
In this case, we're going to give users the ability to trigger an existing job/project in Jenkins.
We'll obtain the list of available plans using Bamboo REST API which we'll present to the user. Then, we trigger the build after the user confirms some options.
Bamboo configuration
The project itself is a normal one; the only thing relevant to mention is that this project is a parameterized one, so it receives a TESTPLAN variable, that in our case will be coming from Jira.
The final task submits the results linking the Test Execution to the Test Plan passed as an argument.
Power Actions configuration
We need to configure the Power Action custom field created earlier, namely the Condition, Screen, and Action Scripts; this from the custom field configuration as follows.
A new button will be available on the custom field. You'll need to add it to the view issue screen.
From the "plan" dropdown you can select the plan you want to run. You can also specify whether you want to report the results back to the current Test Plan and if you want to set that job as the default one for that Test Plan (so it pre-selected the next time you invoke it).
Display progress information, as text, on Test Execution issues
The idea is to display information about the number of passed, failed, etc tests as text, on Test Execution issues using a specific custom field.
Therefore, we'll use the Power Custom Fields app.
- create the custom script using the "PCFU - SIL Script Custom Field" type
- configure the custom field by defining the respective SIL script; in this case we'll just return the value of "Test Execution Status" custom field, as it already provides a textual representation with what we need
Now you can add this custom field on the Test Execution view issue screen if you want. In this specific case, it would be a bit redundant though, as the progress bar bellow shows those values.
You can also add it as a column on panels that show Test Executions (e.g. on the Test Plan).
Learn more
- Power Scripts
- Power Custom Fields for Jira
- Power Actions for Jira
- SIL (Simple Issue Language) usage
- Routines/functions to interact with Jira
- Logging from the scripts
- Environment variables