AgentSkillsCN

Reportburster Scripting

Reportburster 脚本编写

SKILL.md

Scripting Skill

I help users extend ReportBurster with custom Groovy scripts for advanced report distribution scenarios — things the standard UI doesn't cover out of the box.

When Scripting Is Needed

Standard UI handles most distribution. Scripting is for:

  • Zipping output files together
  • Encrypting/password-protecting reports
  • Printing reports to physical printers
  • Uploading via FTP/SFTP/HTTP with custom logic
  • Fetching distribution details from database or CSV
  • Conditional distribution (skip files based on size, content, etc.)
  • Merging reports with external documents
  • Calling external programs (pdftk, Foxit Reader, etc.)

Burst Lifecycle Events

Scripts hook into predefined exit points during bursting:

EventWhen It Fires
startBurstingBurst begins
startParsePage / endParsePageBefore/after each page is parsed
startExtractDocument / endExtractDocumentBefore/after each report is extracted
startDistributeDocument / endDistributeDocumentBefore/after each report is distributed
quarantineDocumentWhen distribution fails
endBurstingBurst completes

Most Common Hooks:

  • endExtractDocument — the go-to event for most scenarios. Fires after each report is extracted, perfect for per-file operations (zip, encrypt, upload, conditional skip). Example: Upload reports to the Self-Service Web Portal via cURL + REST API — if it's a custom Grails/NextJS portal, use the API you built; if it's WordPress-powered, use the WordPress REST API.
  • startDistributeDocument — ideal for conditional distribution based on custom business logic (set ctx.skipCurrentFileDistribution = true to skip sending a report).
  • endBursting — useful for batch operations after all reports are processed (summary email, cleanup, final upload).

Scripts live in scripts/burst/ — one file per event (e.g., endBursting.groovy, endExtractDocument.groovy).


The Bursting Context (ctx)

Scripts access the ctx object with runtime information:

  • ctx.token — current burst token
  • ctx.extractedFilePath — path to current extracted file
  • ctx.outputFolder, ctx.quarantineFolder — folder paths
  • ctx.variables — access built-in and user variables
  • ctx.settings — current configuration settings
  • ctx.skipCurrentFileDistribution — set to true to skip distribution
  • ctx.numberOfExtractedFiles, ctx.numberOfDistributedFiles — counters

Sample Scripts

ReportBurster includes ready-to-use samples in scripts/burst/samples/:

ScriptPurpose
zip.groovyZip all output files together
encrypt.groovyPassword-protect PDFs
print.groovySend to printer
copy_shared_folder.groovyCopy to network share
ant_ftp.groovy, ant_scp_sftp.groovyUpload via FTP/SFTP
curl_ftp.groovy, curl_sftp.groovyUpload via cURL
fetch_distribution_details_from_database.groovyFetch recipient info from DB
fetch_distribution_details_from_csv_file.groovyFetch recipient info from CSV
skip_current_file_distribution_if.groovyConditional distribution
merge_with_external_files.groovyMerge PDFs
add_and_format_page_numbers.groovyAdd page numbers
rclone_sync_cloud.groovySync to cloud storage

cURL Integration

cURL handles uploads for FTP, FTPS, SFTP, HTTP, HTTPS, and more. ReportBurster bundles cURL on Windows.

Sample scripts: curl_ftp.groovy, curl_sftp.groovy

Common options:

  • --ftp-create-dirs — create missing directories
  • -T <file> — upload file
  • -u user:password — authentication
  • -v or --trace — debugging

How I Use This Knowledge

When users need custom distribution logic:

  1. I identify which lifecycle event fits their requirement
  2. I read the relevant sample script in scripts/burst/samples/
  3. I understand the pattern, then give them a customized script
  4. I tell them which file to paste it into (e.g., scripts/burst/endExtractDocument.groovy)

My Working Mode (Read-Only)

I read sample scripts and documentation to understand patterns. I don't write files directly.

When I provide Groovy scripts, I:

  1. Explain what the script does
  2. Give the complete code to copy
  3. Tell the user exactly where to paste it (e.g., scripts/burst/endBursting.groovy)

Documentation Links

When I need specifics on lifecycle events, ctx variables, or cURL options, I fetch these docs.


My Principle

Sample Scripts Are Starting Points. I read the samples to understand patterns — zip, encrypt, upload, conditional skip. Then I customize for the user's specific need. Most scripting requirements are variations of existing samples.