Leantime Timesheets pulls timesheet, generates a CSV, and emails summary per user.
1.8K
Exports timesheets from Leantime via JSON-RPC (API key), converts timestamps UTC β local calendar dates, writes a CSV, and sends a summary email per user. Runs once or on a cron schedule in a tiny Alpine-based container.
Europe/Zurich) with robust date parsinglast_day, last_week, last_month (for cron automation)x-api-key) to Leantime JSON-RPCHeader (semicolon-separated):
date;hours;client;projectId;projectName;ticketId;ticketTitle;type;description
Dates use CSV_DATE_STRFTIME (default "%d.%m.%Y" β e.g., 22.09.2025).
docker run --rm \
-e LEANTIME_API_URL="https://planner.example.com/api/jsonrpc" \
-e LEANTIME_API_KEY="YOUR_API_KEY" \
-e LEANTIME_USERS="[email protected],[email protected]" \
-e LEANTIME_PERIOD="last_week" \
-e LOCAL_TZ="Europe/Zurich" \
-e SMTP_HOST="smtp.office365.com" \
-e SMTP_PORT=587 \
-e SMTP_STARTTLS=true \
-e SMTP_USERNAME="[email protected]" \
-e SMTP_PASSWORD="****" \
-e SMTP_FROM="Timesheets Bot <[email protected]>" \
-v $(pwd)/out:/app/out \
onesystems/leantime-timesheets:latest
services:
leantime-timesheets:
image: onesystems/leantime-timesheets:latest
restart: unless-stopped
env_file: .env # optional, or use environment: below
environment:
LEANTIME_API_URL: https://planner.example.com/api/jsonrpc
LEANTIME_API_KEY: ${LEANTIME_API_KEY}
LEANTIME_USERS: [email protected], [email protected]
LEANTIME_PERIOD: last_week # last_day | last_week | last_month
LOCAL_TZ: Europe/Zurich
CSV_DATE_STRFTIME: "%d.%m.%Y"
SMTP_HOST: smtp.office365.com
SMTP_PORT: 587
SMTP_STARTTLS: "true"
SMTP_SSL: "false"
SMTP_USERNAME: [email protected]
SMTP_PASSWORD: ${SMTP_PASSWORD}
SMTP_FROM: "Timesheets Bot <[email protected]>"
# Optional:
# SMTP_EXTRA_TO: [email protected]
# ADMIN_CC:
# TIMESHEETS_BCC_ALL:
# STRICT_USER_FILTER: "true"
# RESOLVE_TICKET_TITLES: "false"
# DEBUG: "false"
# CRON_SCHEDULE: "0 7 * * 1" # run every Monday 07:00
volumes:
- ./out:/app/out
If
CRON_SCHEDULEis not set, the container runs the job once and exits. If set (e.g.,"0 7 * * 1"), cron runs the job periodically and the container stays up.
LEANTIME_API_URL β e.g., https://planner.example.com/api/jsonrpcLEANTIME_API_KEY β API key for x-api-key headerLEANTIME_PERIOD β last_day | last_week | last_monthLEANTIME_USERS β comma/semicolon-separated list of emailsLEANTIME_START, LEANTIME_END β YYYY-MM-DD (overrides LEANTIME_PERIOD if both set)LOCAL_TZ β local zone for calendar dates (default Europe/Zurich)SERVER_TZ β ignored for epoch; kept for compatibility (default UTC)CSV_DATE_STRFTIME β default "%d.%m.%Y"SMTP_HOST, SMTP_PORTSMTP_STARTTLS (true/false), SMTP_SSL (false/true)SMTP_USERNAME, SMTP_PASSWORDSMTP_FROM β e.g., Timesheets Bot <[email protected]>SMTP_EXTRA_TO β extra comma/semicolon-separated recipientsADMIN_CC, TIMESHEETS_BCC_ALL β optional listsSTRICT_USER_FILTER β default true (keeps only rows belonging to target user)RESOLVE_TICKET_TITLES β default false (reserved for future enrichments)DEBUG β default false (prints RPC calls and caches)CRON_SCHEDULE β empty = run once; otherwise standard crontab (e.g., 0 7 * * 1)TZ (default Europe/Zurich in the image)Determines the period (last_day, last_week, last_month) based on local time.
Queries Leantime via JSON-RPC with the API key.
Normalizes timestamps (epoch/ISO) as UTC, then converts to LOCAL_TZ calendar dates.
Builds a Client value from:
Client // Project title (robust split), orclientName, company, etc.), orWrites a CSV to /app/out.
Sends one email per user (skips if total hours <= 0).
Every Monday at 07:00 (previous week):
CRON_SCHEDULE=0 7 * * 1
LEANTIME_PERIOD=last_week
First day of month at 08:30 (previous month):
CRON_SCHEDULE=30 8 1 * *
LEANTIME_PERIOD=last_month
CRON_SCHEDULE: runs once and exits (good for ad-hoc / CI).CRON_SCHEDULE: keeps running; cron triggers the job and logs to stdout (/var/log/cron.log inside container).LEANTIME_API_URL (must include https://β¦/api/jsonrpc) and LEANTIME_API_KEY.Client // Project, or that project metadata includes a client/customer/company field. The tool caches both.LOCAL_TZ, host timezone mounts, and CSV format CSV_DATE_STRFTIME.env_file or Docker secrets.MIT License β free for commercial and private use.
Content type
Image
Digest
sha256:f6bb662b5β¦
Size
20 MB
Last updated
12 months ago
docker pull onesystems/leantime-timesheets