Skip to content

Instantly share code, notes, and snippets.

@Kuanlin-Chen
Created February 23, 2019 09:14
Show Gist options
  • Save Kuanlin-Chen/5abece706ac450d644677d770ae49ec9 to your computer and use it in GitHub Desktop.
Save Kuanlin-Chen/5abece706ac450d644677d770ae49ec9 to your computer and use it in GitHub Desktop.
Check command exists or not in Gradle.
task checkCommand{
doLast{
def result = exec{
def command = "command -v docker"
ignoreExitValue = true
executable "bash" args "-l", "-c", command
}
if(result.getExitValue()==0){
println "Has Docker"
}else{
print "No Docker"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment