close
The Wayback Machine - https://web.archive.org/web/20201128171508/https://github.com/lnxjedi/gopherbot
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
bot
 
 
 
 
 
 
 
 
doc
 
 
 
 
 
 
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Gophers+bot by Renee French, cropped, cc3.0

Gophers + Robot by Renee French (cropped) licensed under Creative Commons License 3.0

Gopherbot DevOps Chatbot

CircleCI Coverage Status GoDoc

Enterprise Slack(*) DevOps / ChatOps / CI/CD bot for Linux, supporting extensions in Go, Python, Ruby, and Bash

Slogans under consideration:

  • The Co-worker that Never Sleeps
  • The DevOps Swiss-Army Chainsaw

Building from Source

With Gopherbot version 2 defaulting to a modular build (to avoid, e.g. linking in go-aws when it's not used), I've stopped building downloadable artifacts, since they were linked to the glibc on the build system.

Requirements:

  • A recent (1.14+) version of Go
  • Standard build utilities; make, tar, gzip

Steps:

  1. Clone this repository
  2. make dist in the repository root
  3. Follow installation instructions at https://lnxjedi.github.io/gopherbot/

Container Builds

Version 2 and onward will be primarily built and released as containers:

Like other projects, the latest tag will always be built from the most recent code, and released versions will have version tags.

Release Status

Version 2 is nearing release. I've accepted that up-to-date documentation will lag the release significantly.

Documentation

The latest documentation for Version 2 is on Github Pages: https://lnxjedi.github.io/gopherbot

Documentation for v1 can be found in the /doc subdirectory of the old archives.


Image

(*) with a modular interface for writing other protocol connectors in Go

Gopherbot Version 2.0 (Unreleased)

Documentation and tests for version 2 are not yet finished, but configuration and API interfaces have settled to the point that the 2.0 snapshots are worth a look. Though it is stable and running in production for me, 2.0 is mostly for current users that are willing to do some digging around until documentation is finished and it's had more time to ripen. There will be a few more breaking changes before a full release.

New Features

The biggest driver for version 2 is to remove the need for a separate CI/CD system. While Gopherbot couldn't replace Jenkins for many shops, it's very lightweight and perfectly adequate for many automated build / test and scheduled job workloads. Gopherbot is already building, running tests, and publishing itself; .circleci is only kept around to publish coverage results in a CircleCI-specific way. For a peek at GopherCI pipelines, compare the contents of .circleci to .gopherci.

Incomplete list of features new in 2.0:

  • API support for pipelines and CI/CD operation (see gopherci)
  • Rocket.Chat adapter
  • Scheduled job support
  • Job histories
  • Encryption for secrets and the robot's brain
  • Configuration merging custom with installed defaults; maps are merged, arrays are replaced
  • New default configuration and a wide selection of included external (script) jobs, plugins and tasks
  • Go template substitutions in configuration files for e.g. includes, referencing environment variables or decrypting secrets
  • An Ansible Playbook
  • First-class container support; ability to bootstrap a robot with a few environment variables and no persistent volumes
  • Go loadable modules, enabling new Go plugins at runtime

Features since 1.x:

  • Built-in support for elevated commands requiring MFA (ala 'sudo')
  • A prompting API for interactive plugins
  • Comprehensive set of administrative commands
  • Support for simple single-file script plugins

Breaking Changes

Breaking changes are documented in the new manual

Deprecated and Unsupported Platforms

The Windows port has been removed; the only known use case is being replaced. Gopherbot should build on Darwin (Mac OS X), but since builds with module support won't cross-compile, archives are no longer being generated.

Documentation

With Version 2 nearly feature complete, documentation has become a priority. Watch https://lnxjedi.github.io/gopherbot for (hopefully) frequent updates. One of the best sources of documentation are the configuration repositories for Floyd (the production 'bot that builds all releases) and Clu (the devel 'bot that runs on my laptop); they can be found at Github.

Other than commented configuration files, most documentation is in the doc/src/ folder. Stuff in doc/src/Outdated is just that.

Sample Plugin with the Ruby API

#!/usr/bin/ruby
require 'net/http'
require 'json'

# NOTE: A bot administrator should supply the API key with a DM:
# `store task parameter weather OWM_APIKEY=xxxx`. Defaults for
# DEFAULT_COUNTRY and TEMP_UNITS can be overridden in custom
# conf/plugins/weather.yaml

# load the Gopherbot ruby library and instantiate the bot
require ENV["GOPHER_INSTALLDIR"] + '/lib/gopherbot_v1'
bot = Robot.new()

defaultConfig = <<'DEFCONFIG'
Help:
- Keywords: [ "weather" ]
  Helptext: [ "(bot), weather in <city(,country) or zip code> - fetch the weather from OpenWeatherMap" ]
CommandMatchers:
- Command: weather
  Regex: '(?i:weather (?:in|for) (.+))'
DEFCONFIG

command = ARGV.shift()

case command
when "configure"
	puts defaultConfig
	exit
when "weather"
    location = ARGV.shift()
    location += ",#{ENV["DEFAULT_COUNTRY"]}" unless location.include?(',')
    uri = URI("http://api.openweathermap.org/data/2.5/weather?q=#{location}&units=#{ENV["TEMP_UNITS"]}&APPID=#{ENV["OWM_APIKEY"]}")
    d = JSON::parse(Net::HTTP.get(uri))
    if d["message"]
        bot.Say("Sorry: \"#{d["message"]}\", maybe try the zip code?")
    else
        w = d["weather"][0]
        t = d["main"]
        bot.Say("The weather in #{d["name"]} is currently \"#{w["description"]}\" and #{t["temp"]} degrees, with a forecast low of #{t["temp_min"]} and high of #{t["temp_max"]}")
    end
end

Contributing

I've started playing around with Gitpod for development, with good results. The shortest path to developing Gopherbot:

  • Sign up with Gitpod
  • Fork this repository
  • Visit https://gitpod.io/#https://github.com/<your-user-name>/gopherbot
  • Go to "File", "Open Workspace...", and open gitpod.theia-workspace (this lets the Go language server work)

For development, testing, and collaboration, feel free to shoot me an email for an invite to the LinuxJedi Slack team.

You can’t perform that action at this time.