From b1e4986a08fbd4f34728462149536ba2001e2c6e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 18 Nov 2016 14:53:51 +0000 Subject: [PATCH] Add Travis-CI --- pkg/github.com/index.html | 11 + pkg/github.com/matrix-org/go-neb/index.html | 11 + .../matrix-org/go-neb/matrix/index.html | 8 +- .../go-neb/services/guggy/index.html | 4 +- .../matrix-org/go-neb/services/index.html | 11 + .../go-neb/services/travisci/index.html | 363 ++++++++++++++++++ pkg/github.com/matrix-org/index.html | 11 + 7 files changed, 413 insertions(+), 6 deletions(-) create mode 100644 pkg/github.com/matrix-org/go-neb/services/travisci/index.html diff --git a/pkg/github.com/index.html b/pkg/github.com/index.html index fed5022..1457183 100644 --- a/pkg/github.com/index.html +++ b/pkg/github.com/index.html @@ -1021,6 +1021,17 @@ + + + travisci + + + Package travisci implements a Service capable of processing webhooks from Travis-CI. + + + + + types diff --git a/pkg/github.com/matrix-org/go-neb/index.html b/pkg/github.com/matrix-org/go-neb/index.html index 361e175..aed8dfc 100644 --- a/pkg/github.com/matrix-org/go-neb/index.html +++ b/pkg/github.com/matrix-org/go-neb/index.html @@ -353,6 +353,17 @@ + + + travisci + + + Package travisci implements a Service capable of processing webhooks from Travis-CI. + + + + + types diff --git a/pkg/github.com/matrix-org/go-neb/matrix/index.html b/pkg/github.com/matrix-org/go-neb/matrix/index.html index df73587..aa90b27 100644 --- a/pkg/github.com/matrix-org/go-neb/matrix/index.html +++ b/pkg/github.com/matrix-org/go-neb/matrix/index.html @@ -326,7 +326,7 @@ Client represents a Matrix client. -

func NewClient

+

func NewClient

func NewClient(httpClient *http.Client, homeserverURL *url.URL, accessToken, userID string) *Client

NewClient creates a new Matrix Client ready for syncing @@ -385,7 +385,7 @@ SetDisplayName sets the user's profile display name -

func (*Client) StopSync

+

func (*Client) StopSync

func (cli *Client) StopSync()

StopSync stops the ongoing sync started by Sync. @@ -396,7 +396,7 @@ StopSync stops the ongoing sync started by Sync. -

func (*Client) Sync

+

func (*Client) Sync

func (cli *Client) Sync()

Sync starts syncing with the provided Homeserver. This function will be invoked continually. @@ -419,7 +419,7 @@ UploadLink uploads an HTTP URL and then returns an MXC URI. -

func (*Client) UploadToContentRepo

+

func (*Client) UploadToContentRepo

func (cli *Client) UploadToContentRepo(content io.Reader, contentType string, contentLength int64) (string, error)

UploadToContentRepo uploads the given bytes to the content repository and returns an MXC URI. diff --git a/pkg/github.com/matrix-org/go-neb/services/guggy/index.html b/pkg/github.com/matrix-org/go-neb/services/guggy/index.html index 99da79c..85e8c6e 100644 --- a/pkg/github.com/matrix-org/go-neb/services/guggy/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/guggy/index.html @@ -190,7 +190,7 @@ ServiceType of the Guggy service -

type Service

+

type Service

type Service struct {
     types.DefaultService
     // The Guggy API key to use when making HTTP requests to Guggy.
@@ -220,7 +220,7 @@ Example request:
 
 			
 				
-				

func (*Service) Commands

+

func (*Service) Commands

func (s *Service) Commands(client *matrix.Client) []types.Command

Commands supported: diff --git a/pkg/github.com/matrix-org/go-neb/services/index.html b/pkg/github.com/matrix-org/go-neb/services/index.html index 83cd0b1..b653771 100644 --- a/pkg/github.com/matrix-org/go-neb/services/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/index.html @@ -184,6 +184,17 @@ + + + + travisci + + + Package travisci implements a Service capable of processing webhooks from Travis-CI. + + + + diff --git a/pkg/github.com/matrix-org/go-neb/services/travisci/index.html b/pkg/github.com/matrix-org/go-neb/services/travisci/index.html new file mode 100644 index 0000000..89ff64e --- /dev/null +++ b/pkg/github.com/matrix-org/go-neb/services/travisci/index.html @@ -0,0 +1,363 @@ + + + + + + + + travisci - The Go Programming Language + + + + + + + + +

+... +
+ + + + + +
+
+ + +

Package travisci

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

Overview ▾

+

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

+ +
+
+ + + + + + + +

Constants

+ +
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 {
+    types.DefaultService
+
+    // 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: +

+
notifications:
+    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. +

+ + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + diff --git a/pkg/github.com/matrix-org/index.html b/pkg/github.com/matrix-org/index.html index c17c268..1aaf8cf 100644 --- a/pkg/github.com/matrix-org/index.html +++ b/pkg/github.com/matrix-org/index.html @@ -361,6 +361,17 @@ + + + travisci + + + Package travisci implements a Service capable of processing webhooks from Travis-CI. + + + + + types