JIRA描述默認值設置


JIRA描述默認值設置

Setting a Default Value in the Description Field

(在 6.3.6 版本上驗證通過)

The content on this page relates to platforms which are not supported by JIRA. Consequently, Atlassian cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.

 

This page describes how to set a Default Value for the Description field in JIRA. There's a feature request for this at JRA-4812. Please watch and vote on the issue if this is important to you.

There are workarounds to add this functionality. The modification does not persist if you upgrade JIRA so you'll have to re-apply these steps again in the future. Here are directions to set a default value for your Description field in JIRA:

1、Locate and backup the file: WEB-INF/classes/templates/jira/issue/field/description-edit.vm

2、Open that file:

#controlHeader ($action $field.id $i18n.getText($field.nameKey) $fieldLayoutItem.required $displayParameters.get('noHeader'))

## setup some additional parameters

$!rendererParams.put("rows", "12")

$!rendererParams.put("wrap", "virtual")

## let the renderer display the edit component

$rendererDescriptor.getEditVM($!description, $!issue.key, $!fieldLayoutItem.rendererType, $!field.id, $!field.name, $rendererParams, false)

#controlFooter ($action $fieldLayoutItem.getFieldDescription() $displayParameters.get('noHeader'))

3、Add a section like this:

#if($description == '')
#set ($description = 'Put stuff here:')
#end

So, ultimately it should look something like:

#controlHeader ($action $field.id $i18n.getText($field.nameKey) $fieldLayoutItem.required $displayParameters.get('noHeader'))

## setup some additional parameters

$!rendererParams.put("rows", "12")

$!rendererParams.put("wrap", "virtual")

#if($description == '')

#set ($description = 'Put stuff here:')
#end
## let the renderer display the edit component

$rendererDescriptor.getEditVM($!description, $!issue.key, $!fieldLayoutItem.rendererType, $!field.id, $!field.name, $rendererParams, false)

#controlFooter ($action $fieldLayoutItem.getFieldDescription() $displayParameters.get('noHeader'))

 

4、Restart your JIRA instance.

 

  • Adding multi-line values

If you wish to display in the description a default value of: 

1Step 1

2

3Step 2

4​

5Step 3

you'll need to tweak the above instructions a bit:

 

#set ($description = "Step 1\
\
Step 2\
\
Step 3")
#set ($description = $description.replace('\',' '))

OK,修改完成后,到前台創建問題的界面,刷新一下,點擊創建,效果有了。

  • 實踐證明

如將”Step 1…” 替換成輸入中文,生效后,界面將會直接顯示亂碼或者報錯,這個。。。該怎么解決這個問題?待研究。如哪位童鞋知道有解決方法,請告之一下,謝謝。

  • 替換方案

方案吧,也簡單,不用中文,直接用英文。。。目前只能使用英文格式暫時先用着,如下:

#if($description == '')
#set ($description = "[Prerequisite]\
1.\
[Step]\
1.\
2.\
3.\
[Actual Result]\
1.\
2.\
3.\
[Expected Result]\
1.\
2.\
3.")
#set ($description = $description.replace('\',' '))
#end

好了,完成,使用沒有報錯。

  • 參考資料

修改腳本方法參考自官方 https://confluence.atlassian.com/jira/setting-a-default-value-in-the-description-field-166003857.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM