Skip to main content
Kinetic Community

Github Source

This source handles webhook calls from Github to run Task Trees whenever commits are pushed to a repository.

Creating a Source

First download the consumer file and place it into the WEB-INF/consumers directory of your Task application and then restart the web server.

To use the consumer, navigate to the Sources page (underneath the Admin tab) and click Add New Source. When creating a source, the type field essentially tells Kinetic Task which consumer file to use for that source.

github_source.png

Now that we have created a Github source we will be able to develop trees that refer to Github-specifc information like commit and repository data.

Configuring a Webhook

To have Github run our Task Trees we need to use webhooks. Webhooks can call the Task API whenever certain events occur and they will pass information about those event to Task as well.

Start by navigating to the repository home page and clicking the Settings link.

project_home.png

Click the Webhooks & Services link.

project_settings.png

Click the Add webhook button.

webhook_and_services.png

The only thing we need to configure for this example is the Payload URL. We need to set this field to the API route of the Task Tree we wish to run. The API routes use the following format.

https://mytaskserver.mycompany.com/kinetic-task/app/api/v1/run-tree/SOURCE/GROUP/TREE

Given the source "Github", the source group "Test", and the tree name "Push" we would use the following API route. 

https://mytaskServer.mycompany.com/kinetic-task/app/api/v1/run-tree/Github/Test/Push

add_webhook.png

Finally, complete configuration by clicking the Add webhook button.

Source Data

predefined_values.png

When the Github webhook calls the Task API it passes along a JSON string of data. In Task this is referred to as Source Data. The consumer then parses the source data and provides the menu of pre-defined values available within the Tree Builder. An example of the pre-defined values menu is shown on the right.

In the Pre-defined Values section below we describe each of the pre-defined values made available by the Github source.

The Example Source Data section gives an example of real source data that was posted to Kinetic Task from Github.

Pre-defined Values

Head Commit

Id Id of the commit
Message Message associated with the commit
Timestamp Timestamp of the commit
Url URL to the commit page on Github
Added Comma-separated list of files that were added in the commit
Removed Comma-separated list of files that were removed in the commit
Modified Comma-separated list of files that were modified in the commit
Committer Name Full name of the committer
Committer Email Email address of the committer
Committer Username Username of the committer

Repository

Id Id of the repository
Name Name of the repository
Url URL to the repository on Github
Description Description of the repository
Owner Username Owner username of the repository
Owner Email Email address of the repository owner
Private Boolean that indicates whether or not the repository is private
Open Issues Count of the open issues

Example Source Data


{
   "ref":"refs/heads/master",
   "before":"076409ab3646078096b0852aad1166bcedd67b7c",
   "after":"be5fb1245e56fef31b88fcb11ddcd534b2aa8e83",
   "created":false,
   "deleted":false,
   "forced":false,
   "base_ref":null,
   "compare":"https://github.com/skoestler/test/compare/076409ab3646...be5fb1245e56",
   "commits":[
      {
         "id":"be5fb1245e56fef31b88fcb11ddcd534b2aa8e83",
         "distinct":true,
         "message":"Updated README.md",
         "timestamp":"2015-01-15T13:56:00-06:00",
         "url":"https://github.com/skoestler/test/commit/be5fb1245e56fef31b88fcb11ddcd534b2aa8e83",
         "author":{
            "name":"Shayne Koestler",
            "email":"shayne.koestler@kineticdata.com",
            "username":"skoestler"
         },
         "committer":{
            "name":"Shayne Koestler",
            "email":"shayne.koestler@kineticdata.com",
            "username":"skoestler"
         },
         "added":[
         ],
         "removed":[
         ],
         "modified":[
            "README.md"
         ]
      }
   ],
   "head_commit":{
      "id":"be5fb1245e56fef31b88fcb11ddcd534b2aa8e83",
      "distinct":true,
      "message":"Updated README.md",
      "timestamp":"2015-01-15T13:56:00-06:00",
      "url":"https://github.com/skoestler/test/commit/be5fb1245e56fef31b88fcb11ddcd534b2aa8e83",
      "author":{
         "name":"Shayne Koestler",
         "email":"shayne.koestler@kineticdata.com",
         "username":"skoestler"
      },
      "committer":{
         "name":"Shayne Koestler",
         "email":"shayne.koestler@kineticdata.com",
         "username":"skoestler"
      },
      "added":[
      ],
      "removed":[
      ],
      "modified":[
         "README.md"
      ]
   },
   "repository":{
      "id":4497128,
      "name":"test",
      "full_name":"skoestler/test",
      "owner":{
         "name":"skoestler",
         "email":"shayne.koestler@kineticdata.com"
      },
      "private":false,
      "html_url":"https://github.com/skoestler/test",
      "description":"",
      "fork":false,
      "url":"https://github.com/skoestler/test",
      "forks_url":"https://api.github.com/repos/skoestler/test/forks",
      "keys_url":"https://api.github.com/repos/skoestler/test/keys{/key_id}",
      "collaborators_url":"https://api.github.com/repos/skoestler/test/collaborators{/collaborator}",
      "teams_url":"https://api.github.com/repos/skoestler/test/teams",
      "hooks_url":"https://api.github.com/repos/skoestler/test/hooks",
      "issue_events_url":"https://api.github.com/repos/skoestler/test/issues/events{/number}",
      "events_url":"https://api.github.com/repos/skoestler/test/events",
      "assignees_url":"https://api.github.com/repos/skoestler/test/assignees{/user}",
      "branches_url":"https://api.github.com/repos/skoestler/test/branches{/branch}",
      "tags_url":"https://api.github.com/repos/skoestler/test/tags",
      "blobs_url":"https://api.github.com/repos/skoestler/test/git/blobs{/sha}",
      "git_tags_url":"https://api.github.com/repos/skoestler/test/git/tags{/sha}",
      "git_refs_url":"https://api.github.com/repos/skoestler/test/git/refs{/sha}",
      "trees_url":"https://api.github.com/repos/skoestler/test/git/trees{/sha}",
      "statuses_url":"https://api.github.com/repos/skoestler/test/statuses/{sha}",
      "languages_url":"https://api.github.com/repos/skoestler/test/languages",
      "stargazers_url":"https://api.github.com/repos/skoestler/test/stargazers",
      "contributors_url":"https://api.github.com/repos/skoestler/test/contributors",
      "subscribers_url":"https://api.github.com/repos/skoestler/test/subscribers",
      "subscription_url":"https://api.github.com/repos/skoestler/test/subscription",
      "commits_url":"https://api.github.com/repos/skoestler/test/commits{/sha}",
      "git_commits_url":"https://api.github.com/repos/skoestler/test/git/commits{/sha}",
      "comments_url":"https://api.github.com/repos/skoestler/test/comments{/number}",
      "issue_comment_url":"https://api.github.com/repos/skoestler/test/issues/comments/{number}",
      "contents_url":"https://api.github.com/repos/skoestler/test/contents/{+path}",
      "compare_url":"https://api.github.com/repos/skoestler/test/compare/{base}...{head}",
      "merges_url":"https://api.github.com/repos/skoestler/test/merges",
      "archive_url":"https://api.github.com/repos/skoestler/test/{archive_format}{/ref}",
      "downloads_url":"https://api.github.com/repos/skoestler/test/downloads",
      "issues_url":"https://api.github.com/repos/skoestler/test/issues{/number}",
      "pulls_url":"https://api.github.com/repos/skoestler/test/pulls{/number}",
      "milestones_url":"https://api.github.com/repos/skoestler/test/milestones{/number}",
      "notifications_url":"https://api.github.com/repos/skoestler/test/notifications{?since,all,participating}",
      "labels_url":"https://api.github.com/repos/skoestler/test/labels{/name}",
      "releases_url":"https://api.github.com/repos/skoestler/test/releases{/id}",
      "created_at":1338395317,
      "updated_at":"2013-01-09T10:38:31Z",
      "pushed_at":1421351797,
      "git_url":"git://github.com/skoestler/test.git",
      "ssh_url":"git@github.com:skoestler/test.git",
      "clone_url":"https://github.com/skoestler/test.git",
      "svn_url":"https://github.com/skoestler/test",
      "homepage":null,
      "size":112,
      "stargazers_count":1,
      "watchers_count":1,
      "language":null,
      "has_issues":true,
      "has_downloads":true,
      "has_wiki":true,
      "has_pages":false,
      "forks_count":0,
      "mirror_url":null,
      "open_issues_count":0,
      "forks":0,
      "open_issues":0,
      "watchers":1,
      "default_branch":"master",
      "stargazers":1,
      "master_branch":"master"
   },
   "pusher":{
      "name":"skoestler",
      "email":"shayne.koestler@kineticdata.com"
   },
   "sender":{
      "login":"skoestler",
      "id":493921,
      "avatar_url":"https://avatars.githubusercontent.com/u/493921?v=3",
      "gravatar_id":"",
      "url":"https://api.github.com/users/skoestler",
      "html_url":"https://github.com/skoestler",
      "followers_url":"https://api.github.com/users/skoestler/followers",
      "following_url":"https://api.github.com/users/skoestler/following{/other_user}",
      "gists_url":"https://api.github.com/users/skoestler/gists{/gist_id}",
      "starred_url":"https://api.github.com/users/skoestler/starred{/owner}{/repo}",
      "subscriptions_url":"https://api.github.com/users/skoestler/subscriptions",
      "organizations_url":"https://api.github.com/users/skoestler/orgs",
      "repos_url":"https://api.github.com/users/skoestler/repos",
      "events_url":"https://api.github.com/users/skoestler/events{/privacy}",
      "received_events_url":"https://api.github.com/users/skoestler/received_events",
      "type":"User",
      "site_admin":false
   }
}