[Jenkins] Groovy 스크립트로 JOB 이름 일괄 변경하기
개발 Phase등,, 변경에 따라 JOB네임을 일괄 변경해야 할 경우 아래와 같이 작성하여 Script실행 ^^;;
// Groovy script to rename job in Hudson import hudson.model.*; def QA_JOB_PATTERN = ~/^QA_.*$/; //find all jobs starting with "MY_JOB". def TEST_JOB_PATTERN = ~/^TEST_.*$/; //find all jobs starting with "MY_JOB". def PRD_JOB_PATTERN = ~/^PROD_.*$/; //find all jobs starting with "MY_JOB". def QA_NEW_PART = "CBT_" def TEST_NEW_PART = "SANDBOX_" def PRD_NEW_PART = "PROD_" (Hudson.instance.items.findAll { job -> job.name =~ QA_JOB_PATTERN }).each { job_to_update -> println ("Updating job " + job_to_update.name); def new_job_name = job_to_update.name.replaceAll('QA_',QA_NEW_PART); //Append new part to the job name println ("New name: " + new_job_name); job_to_update.renameTo(new_job_name); println ("Updated name: " + job_to_update.name); println("="*80); } (Hudson.instance.items.findAll { job -> job.name =~ TEST_JOB_PATTERN }).each { job_to_update -> println ("Updating job " + job_to_update.name); def new_job_name = job_to_update.name.replaceAll('TEST_',TEST_NEW_PART); //Append new part to the job name println ("New name: " + new_job_name); job_to_update.renameTo(new_job_name); println ("Updated name: " + job_to_update.name); println("="*80); } (Hudson.instance.items.findAll { job -> job.name =~ PRD_JOB_PATTERN }).each { job_to_update -> println ("Updating job " + job_to_update.name); def new_job_name = job_to_update.name.replaceAll('PRD__',PRD_NEW_PART); //Append new part to the job name println ("New name: " + new_job_name); job_to_update.renameTo(new_job_name); println ("Updated name: " + job_to_update.name); println("="*80); }
최근 댓글