Is there a way to find out if the current build is executing as a continuous build?

How can I find out, programmatically, whether the currently executing build is a continuous build?

Context to this question:
I’d like to disable my PushoverAnnouncer in case of continuous build, i.e. only send a notification in case of a normal, non-continuous build.

Chapter 9. Continuous build does not mention a way to do this. Since this is still incubating, I rather ask than searching for a way to do this in the current implementation. That way the answer could be incorporated into the documentation.

if (project.gradle.startParameter.continuous)  {
   // do stuff
1 Like


I tried it like this (instead of this):

println 'continuous:' + gradle.startParameter.continuous
if(!gradle.startParameter.continuous)  {
    PushoverAnnouncer announcer = new PushoverAnnouncer(pushoverAppToken, pushoverUser)
    AnnouncingBuildListener listener = new AnnouncingBuildListener(announcer)

and it’s printing

Waiting for changes to input files of tasks… (ctrl-d to exit)

Change detected, executing build…


It works, partially, because it no longer sends a notification for the project.

But it is still sending a notification for buildSrc. Can I somehow find out if the current build is a “real” project or just buildSrc?

I think this is because you are putting the script in init.d. Are you able to change it to an explicit apply plugin: Pushover in your root project?

I think there is no public api for this. Your best option is to go after the project name / directory i think.

This should work

if ( != "buildSrc") {
   // do stuff

It doesn’t, unfortunately.

  • What went wrong:
    A problem occurred evaluating initialization script.

The root project is not yet available for build.

The idea is that this should always work for all Gradle builds and not just for those which apply a plugin.

Stick your logic inside a gradle.projectsEvaluated {} closure

(note that if your AnnouncingBuildListener also needs this event you might need to fire it manually)

Awesome! That did it!

Thanks a lot. :slightly_smiling: