Created
November 26, 2022 19:28
-
-
Save comdotlinux/65a9e78926b517dc849c3c192db7d2d0 to your computer and use it in GitHub Desktop.
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