Run Gradle publish command if the command present

We have common CI_CD configuration which run publish for all the gradle projects. But some projects doesn’t have gradle publish enabled i.e maven-publish plugin is not added in the build.gradle.
Are there any way to run the gradle command and ignore the error if the command is not present ?

Hi Navin,

I couldn’t find any direct commands in gradle to solve this problem. I find this custom cmd to do the job:

./gradlew tasks | egrep -iw publish; if [ $((?)) -eq 0 ]; then; ./gradlew publish; fi
1 Like