去掉[/etc/hosts]中的“[”和“]”
代碼
def hostFile = "[/etc/hosts]"
println hostFile.replace("[","").replace("]","")
結果
注意
如果處理的對象不是字符串,可以用toString()方法轉換爲字符串
def hostFile = "[/etc/hosts]"
println hostFile.replace("[","").replace("]","")
如果處理的對象不是字符串,可以用toString()方法轉換爲字符串
繼續討論Task定義 回顧一下前一篇文章的例子: task myTask { doLast { println 'hello world!' } }這段腳本定義了一個名爲myTas
延續上一篇文章 上篇文章末尾有一段腳本,定義了一個Task: task 'myTask' { doLast { println 'hello world!' } } 我們已經知道,這段腳
#!groovy timestamps { node(agent_1){ println "xxxx" } node(agent_2){ println "yyyy" }
def now_date=new Date().format(‘yyyyMMddHHmm’) println now_date