Gradle 如何将管道添加到groovy exec命令行?
我正在尝试获取有关特定提交的信息。如何将管道添加到命令行Gradle 如何将管道添加到groovy exec命令行?,gradle,groovy,Gradle,Groovy,我正在尝试获取有关特定提交的信息。如何将管道添加到命令行 def getCommitLog(commit){ def stdout = new ByteArrayOutputStream() exec { ignoreExitValue true workingDir 'my_dir' commandLine 'git', 'log', '--decorate', '|', 'grep', commit standa
def getCommitLog(commit){
def stdout = new ByteArrayOutputStream()
exec {
ignoreExitValue true
workingDir 'my_dir'
commandLine 'git', 'log', '--decorate', '|', 'grep', commit
standardOutput = stdout
}
def retval = stdout.toString().trim()
return retval
它抛出以下错误:
fatal: ambiguous argument '|': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]
fatal:参数“|”不明确:未知修订或路径不在工作树中。
使用“---”将路径与修订分开,如下所示:
'吉特[…]-[…]
可能您可以尝试更改以下内容,即使用列表
发件人:
致:
你能展示一下exec方法是什么样子吗?不能将类为java.lang.String的对象git强制转换为类“int”是的,我用它作为我发布的上面错误的行:commandLine['git','log','--decoration','|','grep',commit]
commandLine 'git', 'log', '--decorate', '|', 'grep', commit
commandLine ['git', 'log', '--decorate', '|', 'grep', 'commit']