Included Tasks

NOTE: This section is incomplete!

Gopherbot ships with a selection of available pipeline tasks, listed here alphabetically. Note that the given examples use bash syntax for simplicity; for ruby and python see the chapter on the Gopherbot API.


email-log - privileged

Usage:

  • FinalTask email-log joe@example.com emily@example.com frank bob
  • FinalTask email-log

Normally used in the fail and final pipelines, emails a copy of the pipeline log. Can also be used with AddTask in the main pipeline, but content will be incomplete.

Notes on the current implementation:
The email function call takes a byte slice for the email body, rather than an io.Reader, meaning the entire body of the message is read in to memory. To limit memory use, Gopherbot allocates a 10MB line-based circular buffer, with maximum 16KB-long lines (terminated by \n), and reads the log to that buffer for emailing. Logs that are longer than 10MB will only send the last 10MB of the log, and lines longer than 16KB will be truncated.


pause-brain - privileged

Usage: AddTask pause-brain

Pause brain operations for backups and restores. After half a minute, the brain automatically resumes; best practice is to add resume-brain after the backup/restore task.


pause-brain

Usage: AddTask pause <seconds>

Causes the pipeline to pause for a number of seconds before proceeding to the next task. Useful when triggering an external process that there's no easy way to poll for completion.


restart-robot - privileged

Usage: AddTask restart-robot

Allow a privileged pipeline to queue a restart of the robot after the pipeline completes. Heavily used by bootstrap and setup plugins. NOTE: This behavior means that tasks added after restart-robot are actually completed before the restart. In practice, the current pipeline will change the state of the robot, and after restarting a plugin init function will check for the state change (e.g. presence of .restore file) and start a new pipeline.


resume-brain - privileged

Usage: AddTask resume-brain

Resume brain functions after backup/restore.


robot-quit - privileged

Usage: AddTask robot-quit

Special purpose task; once called, the robot will exit as soon as all pipelines have completed, and not allow new pipelines to start.


rotate-log - privileged

Usage: AddTask rotate-log <extension>

Useful for e.g. nightly log rotation jobs, when the robot has been started with e.g.: gopherbot -d -l robot.log. For example:

AddTask rotate-log "log.$(date +%a)"

This would keep daily logs of the form robot.log.Mon, etc.


send-message

Usage: AddTask send-message <str> (...)

Have the robot send a message in the channel, normally to report status of a build. Can be a single long string, or multiple strings; in the case of multiple strings they will be joined with a space separator.


tail-log

Usage: AddTask tail-log or FailTask tail-log

Dump the last 2k chars (in even line increments) to the channel. Normally this is used as a FailTask to show the source of the failure.