Unlock a locked Jira custom field using ScriptRunner
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
This KB article provides changes that are out of the scope of Atlassian Support and, therefore, is provided as-is. The steps are only meant to fix problems within Jira, and not necessarily to be used for any locked fields. Consult with Atlassian support before following the steps listed here. Altering locked system fields can introduce unintended side effects in Jira (such as the inability to pre-populate fields during Issue creation) if unexpected changes are made to default fields, such as adding Translation Text to fields that do not permit this by default.
情報
This KB is a variant of Unlock a locked Jira Software custom field if you do not have Scriptrunner, please follow the other KB for steps on how to do this via the SQL database.
症状
In some cases, you may need to unlock a Locked Jira field:
原因
These fields are locked to prevent accidental changes which can subsequently break the operation of Jira. Due to some specific problems, you may need to unlock and alter one of those fields, but can't afford a downtime to unlock the field using the database approach.
ソリューション
It is possible to Unlock and Lock fields using a Groovy Script, as long as you have Script Runner installed.
To use the scripts below, be sure to adjust the fieldname within "getCustomFieldObjectByName('Epic Status')" from the exemplified "Epic Status" to the field name that you actually want to unlock.
- Browse to the Administration section >> Script Runner
In the Console tab you can use the following script to unlock a field:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.config.managedconfiguration.ManagedConfigurationItemService import com.atlassian.jira.issue.CustomFieldManager ManagedConfigurationItemService managedConfigurationItemService = ComponentAccessor.getComponent(ManagedConfigurationItemService) CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName('Epic Status') if (cf) { def mci = managedConfigurationItemService.getManagedCustomField(cf) if (mci) { managedConfigurationItemService.removeManagedConfigurationItem(mci) } }
Once you run the script, you should be able to alter the field normally without a restart. Once you finish altering the field, the following script can be used to lock back the field:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.config.managedconfiguration.ConfigurationItemAccessLevel import com.atlassian.jira.config.managedconfiguration.ManagedConfigurationItemService import com.atlassian.jira.issue.CustomFieldManager ManagedConfigurationItemService managedConfigurationItemService = ComponentAccessor.getComponent(ManagedConfigurationItemService) CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName('Epic Status') if (cf) { def mci = managedConfigurationItemService.getManagedCustomField(cf) if (mci) { def managedConfigurationItemBuilder = mci.newBuilder(); def updatedMci = managedConfigurationItemBuilder .setManaged(true) .setConfigurationItemAccessLevel(ConfigurationItemAccessLevel.LOCKED) .build(); managedConfigurationItemService.updateManagedConfigurationItem(updatedMci); } }