Use Groovy script in SAP Hybris
1. Overview
Groovy is a script programming language based on Java, it is used in the Hybris world to create and run some very quick tasks, like cleaning and testing.
In this Article, I will show how to create and how to run a Groovy script in Hybris.
2. Implementation
The following Groovy script publish a HelloWorldEvent, using EventService.
// import here
import de.hybris.platform.servicelayer.event.EventService
import com.stackextend.training.core.event.HelloWorldEvent
// retrieve beans from Spring context
EventService eventService = spring.getBean("eventService")
// do business logic
HelloWorldEvent event = new HelloWorldEvent("Mouad EL Fakir");
eventService.publishEvent(event);
// return result
return "OK"
Refer to this article for more details about creating the
HelloWorldEvent.
To run the Groovy script, navigate to http://localhost:9001/hac/console/scripting, past the Groovy script under Edit statement, and press Execute.

- Result : display results returned by the script.
- Output : display outputs raised by the script.
- Stack trace : display error thrown by the script.
Change ROLLBACK to COMMIT if you want to persist results in the database.
Solution Architect with 10+ years of experience across full-stack development, DevOps, and enterprise software design. Expert in building scalable architectures, CI/CD pipelines, and internal developer platforms using tools like GitHub Actions, Terraform, Kubernetes (AKS), Azure, and Prometheus. Strong hands-on background in Java, Spring, Node.js, and event-driven systems (Kafka, Mulesoft). Passionate about developer experience, software quality, and platform engineering