コード
def domain=['out','open','vid','uuu','rrrr','tttt','kkk','rrr','ppp','rfde','wsaq']
def splitCount = 5
for (i in 0..Math.ceil(domain.size() / splitCount) -1 ) {
//開始index
def firstIndex = i == 0 ? i : i * splitCount
//終了index
def lastIndex = (firstIndex + splitCount - 1) < domain.size() - 1 ? (firstIndex + splitCount - 1) : domain.size() - 1
print "start:" + firstIndex + "\n"
print "end:" + lastIndex + "\n"
print "get list:" + domain[firstIndex..lastIndex] + "\n"
}
結果
start:0
end:4
get list:[out, open, vid, uuu, rrrr]
start:5
end:9
get list:[tttt, kkk, rrr, ppp, rfde]
start:10
end:10
get list:[wsaq]