Groovy腳本在Jenkins中的應用(3)

發表于:2013-12-18來源:扛一肩記憶作者:Bob.B點擊數: 標簽:Groovy
同理,我們可以獲取Git的提交歷史: //enter to the exist folder, and get the commit list def proca = [ bash, -c, cd /root/temp/test.git; git log --all -20 --pretty=\%h\ ] //trans the str

  同理,我們可以獲取Git的提交歷史:

  //enter to the exist folder, and get the commit list

  def proca = [ 'bash', '-c', 'cd /root/temp/test.git; git log --all -20 --pretty=\"%h\"' ]

  //trans the str to list by line sep.

  proca.execute().text.tokenize('\n')

1
2
3
4
5
//enter to the exist folder, and get the commit list
def proca = [ 'bash', '-c', 'cd /root/temp/test.git; git log --all -20 --pretty=\"%h\"' ]
 
//trans the str to list by line sep.
proca.execute().text.tokenize('\n')

  當我們點擊“build with parameter”的時候,我們看到的效果是,實時的動態列表已經生成了:

  Groovy的應用場景還有很多很多,這里就不做具體的介紹了,大家有空可以研究研究,當然,前提是你需要稍微有一點Groovy或者Java的基礎才行。Groovy腳本絕對能讓你的CI工作事半功倍。

原文轉自:hhttp://scmbob.org/groovy-in-jenkins.html

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97