1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| import hudson.model.* def str_view = "2dev前端" def str_new_view = "test" def str_search = "-dev" def str_replace = "-dev-copy"
def view = Hudson.instance.getView(str_view) Hudson.instance.addView(new ListView(str_new_view)) for(item in view.getItems()) { if (!item.getName().contains(str_search)) { continue } newName = item.getName().replace(str_search, str_replace) def job try { job = Hudson.instance.copy(item, newName) } catch(IllegalArgumentException e) { println("$newName job is exists") continue } catch(Exception e) { println(e.toString()) continue }
job.save() println(" $item.name copied as $newName is success") }
|