Skip to content

Instantly share code, notes, and snippets.

@tenten0213
Created October 19, 2012 08:01
Show Gist options
  • Save tenten0213/3916843 to your computer and use it in GitHub Desktop.
Save tenten0213/3916843 to your computer and use it in GitHub Desktop.
JenkinsでSVNのロケーションを切り替えるスクリプト。
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()
}
}
}
@tenten0213
Copy link
Author

Groovyっぽい書き方が分からない…
ファイルの読み書きあたり、もう少し綺麗に書ける気がする。

Jenkinsのconfig.xmlって設定の再読込しなきゃ読み込まれないのだろうか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment