Package travisci

import "github.com/matrix-org/go-neb/services/travisci"

Overview ▾

Package travisci implements a Service capable of processing webhooks from Travis-CI.


const DefaultTemplate = (`%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}
    Change view : %{compare_url}
    Build details : %{build_url}`)

DefaultTemplate contains the template that will be used if none is supplied. This matches the default mentioned at: https://docs.travis-ci.com/user/notifications#Customizing-slack-notifications

const ServiceType = "travis-ci"

ServiceType of the Travis-CI service.

type Service

type Service struct {

    // The URL which should be added to .travis.yml - Populated by Go-NEB after Service registration.
    WebhookURL string `json:"webhook_url"`
    // A map from Matrix room ID to Github-style owner/repo repositories.
    Rooms map[string]struct {
        // A map of "owner/repo" to configuration information
        Repos map[string]struct {
            // The template string to use when creating notifications.
            // This is identical to the format of Slack Notifications for Travis-CI:
            // https://docs.travis-ci.com/user/notifications#Customizing-slack-notifications
            // The following variables are available:
            //   repository_slug: your GitHub repo identifier (like svenfuchs/minimal)
            //   repository_name: the slug without the username
            //   build_number: build number
            //   build_id: build id
            //   branch: branch build name
            //   commit: shortened commit SHA
            //   author: commit author name
            //   commit_message: commit message of build
            //   commit_subject: first line of the commit message
            //   result: result of build
            //   message: Travis CI message to the build
            //   duration: total duration of all builds in the matrix
            //   elapsed_time: time between build start and finish
            //   compare_url: commit change view URL
            //   build_url: URL of the build detail
            Template string `json:"template"`
        } `json:"repos"`
    } `json:"rooms"`
    // contains filtered or unexported fields

Service contains the Config fields for the Travis-CI service.

This service will send notifications into a Matrix room when Travis-CI sends webhook events to it. It requires a public domain which Travis-CI can reach. Notices will be sent as the service user ID.

Example JSON request:

    rooms: {
        "!ewfug483gsfe:localhost": {
            repos: {
                "matrix-org/go-neb": {
                    template: "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}\nBuild details : %{build_url}"

func (*Service) OnReceiveWebhook

func (s *Service) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)

OnReceiveWebhook receives requests from Travis-CI and possibly sends requests to Matrix as a result.

If the repository matches a known Github repository, a notification will be formed from the template for that repository and a notice will be sent to Matrix.

Go-NEB cannot register with Travis-CI for webhooks automatically. The user must manually add the webhook endpoint URL to their .travis.yml file:

    webhooks: http://go-neb-endpoint.com/notifications

See https://docs.travis-ci.com/user/notifications#Webhook-notifications for more information.

func (*Service) PostRegister

func (s *Service) PostRegister(oldService types.Service)

PostRegister deletes this service if there are no registered repos.

func (*Service) Register

func (s *Service) Register(oldService types.Service, client *matrix.Client) error

Register makes sure the Config information supplied is valid.