How do you execute shell script in gradle, and che...
# community-support
s
How do you execute shell script in gradle, and check exit status? I have very simple task that is defined below - what I am finding is the script get executed perfectly but I always get error. Could not get unknown property ‘execResult’ for task ‘myapprunScriptAndCheckExitCode’ of type org.gradle.api.tasks.Exec. My shell script exit with code 1 if there was problem, and on sucess exit with code 0. But why am I getting this issue with property execResult. I am using gradle version 8.6 task runScriptAndCheckExitCode(type: Exec) { String aabPath = "./someaabpath.aab" commandLine("/bin/sh", "-c", "./../scripts/apk-size-check.sh $aabPath") // Replace with your script and argument doLast { if (execResult.exitValue != 0) { throw new GradleException("Script execution failed with exit code") } } }
v
Do you want to check more than == 0 then fail? Because that is the built-in behavior anyway if you don't disable it
👍 1
Besides that, it is
executionResult
.
execResult
was deprecated in Gradle 7 and removed in Gradle 8.
And I strongly recommend switching to Kotlin DSL. By now it is the default, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and an amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.
327 Views