def customFieldToCollect = 'customfield_10321'
def jql = 'project = ATEF AND issuetype = Epic AND key > ATEF-6000 ORDER BY key ASC'
//paginated search
def maxResults = 500
def total = 1
def cur = 0
//results
def fieldValues = []
def epics = []
while(cur < total){
//search for up to 500 issues
def page = get('/rest/api/3/search')
.header('Content-Type', 'application/json')
.queryString('startAt', cur)
.queryString('maxResults', maxResults)
.queryString('jql', jql)
.queryString('fields', customFieldToCollect)
.asObject(Map).getBody()
total = page["total"]
def issues = page["issues"] as List<Map>
cur += issues.size() //REST API is stupid and may return less than 500 even if there are more.
epics.addAll(issues)
}
//Sort the field values in ascending order
epics.each{epic ->
def eingStat = epic["fields"][customFieldToCollect] as List
eingStat = eingStat.collect{it["value"]}
def test = put("/rest/api/3/issue/" + epic["key"])
    .header('Accept', 'application/json')
    .header('Content-Type', 'application/json')
    .queryString("overrideScreenSecurity", true)
    .body(
        [fields:
            [customfield_10308: [
                value: eingStat[eingStat.size()-1] 
            ]
        ]
    ])
    .asObject(Map).getBody()
logger.warn( [fields:
            [customfield_10308: [
                value: eingStat[eingStat.size()-1] 
            ]
        ]
    ].toString())
}
Behalt bitte das Script so gut wie möglich in seiner Form. Bitte eine Schleife hinzu, die immer wieder läuft und den Key in der Zeile "def jql = 'project = ATEF AND issuetype = Epic AND key > ATEF-6000 ORDER BY key ASC'" immer um 500 erhöht, bis alle Epics abgelesen werden. Fang bitte zwischem dem Key ATEF-1 und ATEF-500 an und erhöh um 500 solange bis alle Epics eingelesen wurden. Das ganze soll bis ATEF-10000 laufen