- Created by Jonathan Muse, last modified on Mar 12, 2024
- Mentions
- 0 Associations
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 7 Next »
Referencing an Issue
By default, the issue standard variables are pre-declared along with their synonyms. For instance,the key is an issue standard variable. You should avoid to re-declare it, since it will lead to subtle errors. We recommend you to prefix your variables with certain string if you are unsure of its name.
There are certain constructs that reflect the issue structure, for instance:
parent.id - refers to the parent id, and it is valid only if this issue is a subtask
TSTP-123.id - refers to the issue TSTP-123 id (on the project TSTP)
%k%.id - (Substitution, see below) refers to the issue designed by k, where k is a string variable already defined, containing a valid issue key, like in this example:
string k = "TSTP-123"; %k%.reporter = currentUser();
Tip
You will see the last construct comes in hand when used in cycles (for, while, do-while) or when creating an issue from SIL.
Substitution
It often happens that you need the value of a variable designated by another value. For example, we might have a custom field that specifies what certain data other field contains. The general syntax for substituting variables is:
%varname%
The above expression will evaluate to the value designated by the variable name contained inside the value of varname.
Example
string myCustomField = "customfield_10000"; // myCustomField is a local variable %myCustomField% = "a value";
Note
While is a very powerful mechanism, please check the substitution variables before they are interpreted as variables. Having an uninitialized or an empty substitution is bad practice.
Standard Variables
Here is a list of the variables that are already defined in a SIL environment and that you can use right away. Note that these are all standard issue fields.
Note
Standard variables can be used without explicitly referencing the issue only when the script has an issue context.
Warning
Please do not redefine them. Redefinition is possible with the loss of the original meaning, so you will have subtle errors in your SIL code.
Variable | Aliases | Type | Read Only | Explanations and Usage |
---|---|---|---|---|
affectedVersions | affectedVersion | string [] | no | The affected versions field of the issue. If attempting to add an invalid value, it will be ignored. |
assignee | - | string | no | The assignee of the issue. Represents the user key, not the real name. |
attachments | attach | string [] | yes | The filenames of the attachments. |
argv | - | string [] | no | This standard variable is used to pass information from one script to another. |
components | component | string [] | no | The components of the issue. If attempting to add an invalid value, it will be ignored. |
created | - | date | yes | The date when the issue was created. |
description | desc | string | no | The description of the issue. |
dueDate | due | date | no | The due date of the issue. |
estimate | est | interval | no | This is displayed as "Remaining" in the Jira interface. Requires Time Tracking. |
environment | env | string | no | The environment of the issue. |
fixVersions | fixVersion | string [] | no | The fix versions field of the issue. If attempting to add an invalid value, it will be ignored. |
id | - | integer | yes | The id of the issue. |
issueCreator | - | string | yes | Represents the user key of the creator. |
issueType | type | string | yes | The name of the issue type. |
issueTypeId | - | string | yes | The id of the issue type. |
key | - | string | yes | The key of the issue. |
labels | - | string [] | no | The labels of the issue. |
originalEstimate | origEstimate | interval | no | The original estimate of the issue. Requires Time Tracking. |
parent | - | string | no | The key of the parent issue. |
parentId | - | integer | no | The id of the parent issue. |
priority | prio | string | no | The name of the priority. |
priorityId | - | string | no | The id of the priority. |
project | prj | string | yes | The key of the project. |
projectId | - | integer | yes | The id of the project. |
reporter | - | string | no | Represents the user key, not the real name of the reporter. |
resolution | res resol | string | no | The name of the resolution. When set will also modify the resolution date. |
resolutionDate | - | date | yes | The current resolution date. If the resolution is modified, the date will also be updated. |
resolutionId | resId resolId | string | no | The id of the resolution. When set will also modify the resolution date. |
securityLevel | security | string | no | The name of the security level. |
securityLevelId | securityId | integer | no | The id of the security level. |
status | - | string | yes | The name of the status. |
statusId | - | string | yes | The id of the status. |
summary | - | string | no | The summary of the issue. |
timeSpent | spent | interval | no | The time spent (logged work) on the issue. Requires Time Tracking. |
updated | - | date | yes | The date when this issue was last updated. It will update automatically after the current transition. |
votes | - | integer | no | The number of votes this issue has. |
watchers | - | string [] | no | The watchers of the issue. The elements in the array are usernames. |
workflow | wrkflw | string | no | The workflow name of the issue. |
workflowId | - | integer | no | The workflow id of the issue. |
- Since the version 5.8.0.0, we will actively deny the attempt to change a read-only field. Previously, we were simply ignoring the requests to change such fields (those marked with a star). In fact, they were still read-only, but we ignored the set requests on them.
It is worth to know that very old versions of SIL were able to change directly the project and the issue type because the internal Jira API allowed it, in certain conditions. However, this is no longer the case.
Custom Fields
Aside from the standard issue fields, you can also access custom fields from SIL selecting from the one of the following three ways:
by id, using the construct customfield_xxxxx - where xxxxx is the ID of the custom field.
by name - don't forget to use #{ and } if the name contains spaces.
by its alias.
Examples
customfield_10000 = "http://bugs.kepler-rominfo.com/browse/TST-1"; // referencing by id External = "http://bugs.kepler-rominfo.com/browse/TST-1"; // referencing by name #{External URL} = "http://bugs.kepler-rominfo.com/browse/TST-1"; // referencing by name with spaces
Note
If you have multiple custom fields with the same name, the Jira API returns the first one it finds.
Contents
- No labels