gradle获取当前git分支名称
要获取当前git分支名称,你可以使用以下Gradle脚本:
task getCurrentBranchName {
doLast {
def result = exec {
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
}
def branchName = result.text.trim()
println "当前git分支名称:$branchName"
}
}
然后在终端运行gradle getCurrentBranchName命令,即可获取当前git分支名称。
原文地址: https://www.cveoy.top/t/topic/iyi8 著作权归作者所有。请勿转载和采集!