Or we can write it this way,
customFieldManager.getCustomFieldObjec (123456L) |
---|
In this case, it is also possible that this field is accidentally deleted and re created; Then its ID value will also change. You still need to find all the scripts in the system that use this code to modify its value.
Or in the following cases, the ID value or name is inconsistent in our production environment or test environment, which will also lead to the script debugged in the test environment, and the script obtained from the production environment can only be run by changing this value one by one.
For the above scenarios, using this plug-in, we can define a fixed variable in it. The value of this variable can be quickly managed visually. After modifying this value, all the changes in the system will take effect, which makes it convenient for us to manage these variables in a unified way, so as to achieve visual and global management of variable scripts used everywhere in our system.
Parameters
In order to manage global parameters and facilitate the maintenance of managers, for example, if an administrator needs to write multiple parameters for interfacing with a third-party system, he can group by these parameters;
Therefore, the global grouping will be distinguished by prefix in this app; When managing parameters, you first need to determine which prefix for them .
Prefix
Prefix information is a definition of grouping global parameters, so prefix management is required.
You can navigate to the prefix information to add and manage prefixes. After saving, the prefix information defined in the system will be displayed.
Key-Value
Key-value is effective information provided for business use. It is allowed to add a key value pair to the corresponding prefix to obtain information through full key in the system.
You can select the prefix defined in the system to query all key value pairs included in this prefix. Of course, you can also modify a key value pair.
If you need to add a new key value pair to a prefix, you can add one. At this time, click "add" to pop up the add interface
Usage
When the key value pair is defined and newly added, its information can be obtained where needed for business processing.
Yes, you can use this kind of com.atlassian.jira.config.properties. Applicationproperties and use its getText() method.
String value = applicationProperties.getString($fullkey) ;
REST API
Get all key-values information for a prefix
REST URL
/rest/gearsproperties/1.0/properties/prefix/{prefixkey}
- Method
get
- Example
/rest/gearsproperties/1.0/properties/prefix/ITDESK
{ "fullkey": "HKTXPROPERTIESKEY.ITDESK.StaffId", "prefix": "ITDESK", "key": "StaffId", "value": "1123" }, { "fullkey": "HKTXPROPERTIESKEY.ITDESK.key1", "prefix": "ITDESK", "key": "key1", "value": "value11" }, { "fullkey": "HKTXPROPERTIESKEY.ITDESK.key2", "prefix": "ITDESK", "key": "key2", "value": "value22" } ]
Get a value for a specific full key
- REST URL
/rest/gearsproperties/1.0/properties/fullkey/{fullkey}
- Method
get
- Example
/rest/gearsproperties/1.0/properties/fullkey/HKTXPROPERTIESKEY.ITDESK.StaffId
[
{ "fullkey": "HKTXPROPERTIESKEY.ITDESK.StaffId", "value": "1123" }
API
First, we define a variable value by this app( prefix is:SCRITRUNNER,KEY is :DEV_OWNER) then its fullkey is:HKTXPROPERTIESKEY.SCRITRUNNER.DEV_OWNER , value is:123456
Your code may be like this
import com.atlassian.jira.config.properties.ApplicationProperties String devOwnerCustomfieldId = applicationProperties.getString("HKTXPROPERTIESKEY.SCRITRUNNER.DEV_OWNER") ; CustomField devOwnerCustomfield = customFieldManager.getCustomFieldObject(Long.parseLong(devOwnerCustomfieldId)); ApplicationUser devOwnerUser = issue.getCustomFieldValue(devOwnerCustomfield); |
---|