Screenshot with Cucumber Groovy

I am working with Cucumber features and Groovy as Step definitions in Katalon Studio. As we have each step in the step definition and wanted to take screen shot when the step is failed (AShot or whatever). I would like to have the code to take the snap and would like to know do we need this in each step definition file. Can you please provide the sample on this to proceed further ?

Please note that, I know the option in “Take Screenshot when execution failed” in settings

Thanks in advance.