trigger_cronjob
Execute scheduled tasks in SAP Commerce Cloud by triggering cron jobs with specific codes for system administration and automation.
Instructions
Trigger a cron job to run
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cronJobCode | Yes | Code of the cron job to trigger |
Implementation Reference
- src/index.ts:438-442 (handler)The MCP tool handler for 'trigger_cronjob': validates the input argument 'cronJobCode' and delegates execution to the HybrisClient's triggerCronJob method.case 'trigger_cronjob': result = await hybrisClient.triggerCronJob( validateString(args, 'cronJobCode', true) ); break;
- src/index.ts:269-278 (schema)Input schema definition for the 'trigger_cronjob' tool, specifying the required 'cronJobCode' string parameter.inputSchema: { type: 'object', properties: { cronJobCode: { type: 'string', description: 'Code of the cron job to trigger', }, }, required: ['cronJobCode'], },
- src/index.ts:266-279 (registration)Registration of the 'trigger_cronjob' tool in the MCP tools array.{ name: 'trigger_cronjob', description: 'Trigger a cron job to run', inputSchema: { type: 'object', properties: { cronJobCode: { type: 'string', description: 'Code of the cron job to trigger', }, }, required: ['cronJobCode'], }, },
- src/hybris-client.ts:647-673 (helper)HybrisClient helper method that implements the core logic for triggering a cron job using a Groovy script executed via the HAC scripting console, leveraging CronJobService to perform the job.async triggerCronJob(cronJobCode: string): Promise<{ success: boolean; message: string }> { // Use Groovy script to trigger cron job const escapedCode = this.escapeGroovyString(cronJobCode); const script = ` import de.hybris.platform.servicelayer.cronjob.CronJobService def cronJobService = spring.getBean("cronJobService") def cronJob = cronJobService.getCronJob("${escapedCode}") if (cronJob == null) { println "CronJob not found: ${escapedCode}" return "NOT_FOUND" } cronJobService.performCronJob(cronJob, true) println "CronJob triggered: ${escapedCode}" return "SUCCESS" `; const result = await this.executeGroovyScript(script); const output = result.output || ''; const execResult = String(result.result || ''); const success = output.includes('triggered') || execResult === 'SUCCESS'; return { success, message: success ? `CronJob ${cronJobCode} triggered` : `Failed to trigger ${cronJobCode}: ${output || execResult || 'Unknown error'}`, }; }