test.groovy 494 B

1234567891011121314151617
  1. // 文件位置
  2. def filePath = "version.txt"
  3. //执行命令
  4. def command = "git name-rev --name-only HEAD"
  5. def process = command.execute()
  6. println "process=" + process
  7. process.waitFor()
  8. def tags = process.text.tokenize()
  9. def tagName = tags[0]
  10. println "tagName=" + tagName
  11. def dateTime = new Date().format("yyMMddHHmm")
  12. def version = "$tagName$dateTime".replace("/","")
  13. println "version=" + version
  14. File file = new File(filePath)
  15. println file.getAbsolutePath()
  16. // 写入文件
  17. file.write(version)