Skip to content

Hooks

Hooks let you run custom shell commands at specific points in the task lifecycle. Use them to trigger notifications, update dashboards, run CI pipelines, or integrate with other tools.

HookTrigger
onMergeRuns after a task is successfully merged via rover merge
onPushRuns after a task branch is pushed via rover push
onCompleteRuns when a task finishes (success or failure), detected via rover list

Add hooks to your rover.json file:

{
"version": "1.2",
"languages": ["typescript"],
"packageManagers": ["npm"],
"hooks": {
"onComplete": ["./scripts/on-complete.sh"],
"onMerge": ["./scripts/on-merge.sh"],
"onPush": ["echo 'Task $ROVER_TASK_ID pushed'"]
}
}

Each hook accepts an array of shell commands. Commands are executed sequentially in the order specified.

Rover passes task information to hooks via environment variables:

VariableDescriptionAvailable In
ROVER_TASK_IDThe task IDAll hooks
ROVER_TASK_BRANCHThe task branch nameAll hooks
ROVER_TASK_TITLEThe task titleAll hooks
ROVER_TASK_STATUSTask status: completed or failedonComplete only

Create a script that notifies your team when a task completes:

scripts/on-complete.sh
#!/bin/bash
echo "Task $ROVER_TASK_ID ($ROVER_TASK_TITLE) finished with status: $ROVER_TASK_STATUS"
# Send a Slack notification
if [ "$ROVER_TASK_STATUS" = "completed" ]; then
curl -X POST -H 'Content-type: application/json' \
--data "{\"text\":\"Task #$ROVER_TASK_ID completed: $ROVER_TASK_TITLE\"}" \
"$SLACK_WEBHOOK_URL"
fi

Make sure to set execute permissions:

Terminal window
chmod +x scripts/on-complete.sh
  • Hooks run in the project directory (where rover.json is located)
  • Commands execute via the shell (sh -c), supporting pipes and complex commands
  • Hooks inherit the current environment plus ROVER_* variables
  • Hook failures are logged as warnings but don’t interrupt the main operation
  • If a hook fails, subsequent hooks in the array still execute
  • The primary command (merge, push, list) completes regardless of hook failures

The onComplete hook only triggers on new status transitions. If a task was already completed and you run rover list again, the hook won’t re-execute.

Send notifications when tasks finish:

{
"hooks": {
"onComplete": [
"curl -X POST https://api.example.com/webhook -d '{\"task\": \"$ROVER_TASK_ID\", \"status\": \"$ROVER_TASK_STATUS\"}'"
]
}
}

Start a CI pipeline when a task branch is pushed:

{
"hooks": {
"onPush": [
"gh workflow run ci.yml --ref $ROVER_TASK_BRANCH"
]
}
}

Close related issues when tasks are merged:

{
"hooks": {
"onMerge": [
"./scripts/close-issue.sh"
]
}
}

Chain multiple commands for a single hook:

{
"hooks": {
"onComplete": [
"echo 'Task $ROVER_TASK_ID completed'",
"./scripts/notify-slack.sh",
"./scripts/update-dashboard.sh"
]
}
}