Skip to content

Instantly share code, notes, and snippets.

@vikrantyadav11
Last active November 1, 2023 16:27
Show Gist options
  • Save vikrantyadav11/8b8312372bd6487c9758f9c8a1998a95 to your computer and use it in GitHub Desktop.
Save vikrantyadav11/8b8312372bd6487c9758f9c8a1998a95 to your computer and use it in GitHub Desktop.
Set Description Template.groovy
import com.atlassian.jira.issue.*
def description = getFieldById("description")
def issuetype = getIssueContext().getIssueType().name
if (issuetype.contains("Bug") || issuetype.contains("Bug sub-task")){
if (!underlyingIssue?.description){
description.setFormValue("""h3.Description
_<Explain the observations as clear as possible>_
*Steps to reproduce*
_<-- minimum steps that describe the entire path of reproducing the bug._
_-- Describe one step per line>_
*Expected result*
_<Describe the expected result according to the technical task, design, test cases outcome>_
*Actual result*
_<Explain the current observation as clear as possible>_
*Attachments (screenshots, files, error log etc)*
_-- Screenshot (it's convenient when the bug is highlighted with a circle or an arrow),_
_-- Files (Uploaded files)_
_-- Error logs_
h4.NOTE (optional)
_-- Any other observations_""")
}
}
@Isranigit
Copy link

@vikrantyadav11 Thanks for replying, i replaced description with Acceptance criteria but its not working, can you pls do favor, can you pls paste it from your end here.
Custom field "Acceptance criteria".

@Isranigit
Copy link

import com.atlassian.jira.issue.*

def acceptancecriteria = getFieldById("acceptancecriteria")

def issuetype = getIssueContext().getIssueType().name

if (issuetype.contains("Story")){

if (!underlyingIssue?.acceptancecriteria){

acceptancecriteria.setFormValue( 
    """h3.acceptancecriteria


Steps to reproduce
<-- minimum steps that describe the entire path of reproducing the bug.
-- Describe one step per line>
Expected result
<Describe the expected result according to the technical task, design, test cases outcome>
Actual result

Attachments (screenshots, files, error log etc)
-- Screenshot (it's convenient when the bug is highlighted with a circle or an arrow),
-- Files (Uploaded files)
-- Error logs
h4.NOTE (optional)
-- Any other observations""")

}

}

@Isranigit
Copy link

This is how i am using but does not work.

@vikrantyadav11
Copy link
Author

@Isranigit

def acceptancecriteria = getFieldById("customfield_12345")

@Isranigit
Copy link

Thanks @vikrantyadav11, still not working. i tried above change as well

@Isranigit
Copy link

Isranigit commented Jul 20, 2023

Its working fine, looks like there was case sensitive issue. and other thing is if (!underlyingIssue?.description){acceptancecriteria.setFormValue( as kept like this....the strange thing is "description" if i replace it with acceptance criteria then this script does not work

But Thanks alot vikrant, i am a newbie..so things are bit challenging at the beginning.
import com.atlassian.jira.issue.*- what's the meaning in technical terms and what is component accessor etc. would you mind explaining in simple form.

@Isranigit
Copy link

@vikrantyadav11 Hi again, is this possible to elseif condition or switch in the same script, for example Issue Type is Bug and acceptance criteria "ABC" and issue type is Incident then acceptance criteria would be "DEF" and so ? kindly help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment