This file contains hidden or 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
| // example1.msgspec | |
| namespace com.example | |
| namespace cpp example | |
| namespace ruby Example | |
| message BasicTypeExample { | |
| 1: int8 f1 | |
| 2: int16 f2 |
This file contains hidden or 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
| @GrabResolver(name='seasar.org', root='http://maven.seasar.org/maven2/') | |
| @Grab('net.arnx.jsonic:jsonic:1.2.0') | |
| import net.arnx.jsonic.JSON | |
| println JSON.encode([ | |
| name:'Kiyotaka OKu', | |
| tags:['java', 'groovy', 'jenkins'] | |
| ]) |
This file contains hidden or 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
| @Grab(group='org.codehaus.groovy', module='groovy-xmlrpc', version='0.7') | |
| @Grab(group='jivesoftware', module='smack', version='3.1.0') | |
| import groovy.net.xmlrpc.XMLRPCServerProxy | |
| // 設定内容 | |
| def SPACE = 'demo' | |
| def USER_ID = 'demo' | |
| def PASSWORD = 'demo' |
This file contains hidden or 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
| def kvmap = [ | |
| key1: "value1", | |
| key2: "value2", | |
| key3: [ | |
| "key3-1" : "value3-1", | |
| "key3-2" : "value3-2", | |
| ], | |
| ] | |
| LinkedHashMap.metaClass.toXml = { builder -> |
This file contains hidden or 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
| // あるプロジェクトの下流ビルドと上流ビルドを取得する方法 | |
| // 以下は groovy plugin の Execute system Groovy script の中で使用して | |
| // TEST プロジェクトの下流ビルドと上流ビルドを取得する例 | |
| def jobname = "TEST" | |
| def job = hudson.model.Hudson.instance.getItem(jobname) | |
| def dep = hudson.model.Hudson.instance.dependencyGraph | |
| assert job, "ERROR: Can't find the job $jobname." | |
| assert dep, "ERROR: Can't get the dependency graph." |
This file contains hidden or 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
| import java.security.MessageDigest | |
| println "-"*40 | |
| println "MessageDigest:" | |
| File.metaClass.getMd5 = { | |
| MessageDigest.getInstance("md5"). | |
| digest(delegate.readBytes()). | |
| collect{ String.format("%02x", it) }. | |
| join() | |
| } |
This file contains hidden or 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
| @GrabResolver(name='m.g.o-public', root='http://maven.glassfish.org/content/groups/public/') | |
| @Grab('org.jenkins-ci.main:cli:1.398') | |
| import hudson.cli.CLI | |
| import javax.swing.* | |
| import groovy.beans.Bindable | |
| import groovy.ui.Console | |
| class JenkinsMenuModel { | |
| @Bindable String url | |
| @Bindable String args = '' |
This file contains hidden or 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
| def array = [] | |
| def tmp = "" | |
| array = ('0'..'9') + ('a'..'z') + ('A'..'Z') + '_' | |
| (1..16).each { | |
| tmp += array[Math.floor(Math.random() * array.size()) as int] | |
| } | |
| println tmp |
This file contains hidden or 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
| // g100pon #40 XMLの読み書きを色んな方法で(DOMBuilder->XmlUtil) | |
| import groovy.xml.XmlUtil | |
| import groovy.xml.dom.DOMCategory | |
| import groovy.xml.DOMBuilder | |
| // DOMBuilderを使うとパースが簡単にできる | |
| // パース結果のオブジェクトはDOM | |
| def doc = DOMBuilder.parse( | |
| new InputStreamReader(new FileInputStream('sample.xml'),'UTF-8') ) |
This file contains hidden or 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
| def test(Closure clos) { | |
| def localVals = new Object() { | |
| def map = [:] | |
| def that | |
| } | |
| clos.delegate = localVals // 参照先を一時変数とする | |
| def arg1 = clos.getResolveStrategy() // デフォルトではowner, delegateの順でメソッドやプロパティの存在を確認 | |
| localVals.that = 'This is that!' // thatで参照できるようにしてみる。 | |
| clos.call(arg1) | |
| localVals.map.each { key, value -> |