Created
October 19, 2012 08:01
-
-
Save tenten0213/3916843 to your computer and use it in GitHub Desktop.
JenkinsでSVNのロケーションを切り替えるスクリプト。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChangeLocation{ | |
static void main(args){ | |
if (args.size()==2) { | |
println "config.xmlを読込み、SVNサーバーのロケーションを書き換えます。" | |
println "置換前:"+ args[0] | |
println "置換後:"+ args[1] | |
println "JOB完了後、Jenkinsの管理から設定の再読み込みを行なってください。" | |
new File("C:/Jenkins/jobs/").eachFile { | |
def target = it.toString()+"\\config.xml" | |
if (new File(target).exists()){ | |
println "対象:"+ target | |
def lines = new File(target).readLines() | |
new File(target).withWriter { writer -> | |
lines.each { line -> writer.writeLine(line.replaceAll(args[0], args[1])) } | |
} | |
} | |
} | |
} else { | |
println "JOBに対する引数が間違っています。古いロケーションと新しいロケーションを指定して下さい。" | |
throw new Exception() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Groovyっぽい書き方が分からない…
ファイルの読み書きあたり、もう少し綺麗に書ける気がする。
Jenkinsのconfig.xmlって設定の再読込しなきゃ読み込まれないのだろうか。