//Search issues from one JQL
Object searchResult = get("/rest/api/3/search")
.queryString('jql', "project = 'NEWONE' and test1 is not Empty")
.asObject(Map)
.body
def getIssue
def duplicate = false
//for every issue get the required custom field ( change the cf customfield_10034 by yours )
for (j = 0; j<searchResult.total; j++){
getIssue = get("/rest/api/3/issue/${searchResult.issues[j].key}?expand=changelog")
.header('Content-Type', 'application/json')
.asObject(Map)
.body
//if the value of this cf is found in a different issue then update the duplicate var
if(getIssue.fields.customfield_10034 == issue.fields.customfield_10034 && getIssue.key != issue.key)
{
logger.info(getIssue.fields.customfield_10034)
logger.info(issue.fields.customfield_10034)
logger.info(getIssue.key)
logger.info(issue.key)
duplicate = true
}
j++;
}
def issueKey = issue.key
//if the cf value is duplicate then set to ""
if (duplicate)
{
//put a value Duplicated or null
def result = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields:[
customfield_10034:""
]
])
.asString()
}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.