trigger_cronjob
Execute scheduled tasks in SAP Commerce Cloud by triggering cron jobs using specific job codes to automate system processes.
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/hybris-client.ts:663-689 (handler)The handler method in HybrisClient that executes a Groovy script to trigger a CronJob by code.
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'}`, }; } - src/index.ts:266-279 (registration)Definition of the trigger_cronjob tool, including input schema and description.
{ 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/index.ts:446-450 (handler)Implementation of the tool call handler for trigger_cronjob in the main index.ts file.
case 'trigger_cronjob': result = await hybrisClient.triggerCronJob( validateString(args, 'cronJobCode', true) ); break;