当我尝试在gradle任务中运行sudo命令时,它向我显示以下错误,并且不要求我提供sudo密码:
➜ myProject ./gradlew startSudoScript
> Task :startSudoScript
sudo: no tty present and no askpass program specified
BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
这是任务的样子:
task startSudoScript(description: "Starts sudo script") {
doLast {
logger.info("script is excuting")
def procScript = exec {
ignoreExitValue = true
executable = "sudo"
args = ["-E", "script.sh"]
}
}
}