"Output parameters" from Gradle Task?

I have the following situation:

My build invokes a gradle task in a plugin. This task simply exec’s scp to copy one or more of the output files built by gradle to a directory on another machine, and prints out some useful output that appears in the Jenkins console output. This build is invoked from Jenkins.

Up to now that behavior has been sufficient. But I want to differentiate the case where the file copied is creating a new file in the target directory from the case where the file overwrites a file of the same name in the target directory, and pass this knowledge as an output parameter back to Jenkins. It’s easy enough to do the checking in the task but how to pass the output new/overwrite distinction back to Jenkins is eluding me.

Does anyone have a solution here?

It seems like you might jumping ahead with looking for solutions before fully defining the problem. It’s not clear what you want to do with the output. Does another Jenkins job and/or another system need to act on the results or is it just informational? It seems like the needs of the consumer would tip the scale to a particular Jenkins plugin, which would consequently dictate the output requirements of the Gradle task to fulfill the plugin’s expectations.

To supply a little more detail, I want to use the Jenkins email facility to send an email to some users based on if the scp command is replacing a file or copying a new file. Most simply this would be done by passing some sort of output parameter. Since that doesn’t seem possible, I’ve written a notation in the build log which a script launched by the email extension plugin would read to make the determination whether to email or not to email. But I haven’t implemented this yet and am open to other solutions.