Get the Output of an External Command into an variable for further use.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream | |
tasks.register("gitCommit") { | |
group = "com.linux" | |
description = "Get The last git commit" | |
doLast { | |
val output = ByteArrayOutputStream().let { os -> | |
exec { | |
commandLine("/usr/bin/git rev-parse --verify HEAD".split(" ")) | |
standardOutput = os | |
} | |
os.toString() | |
} | |
println(output) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment