A Hubot script to integrate GitHub and Microsoft Team Foundation Server (TFS)
npm install hubot-github-tfs
A Hubot script to integrate GitHub and Microsoft Team Foundation Server (TFS).
You can now automatically trigger a TFS build following a push on a pull request and get the build result back.
- In hubot project repo, run:
npm install hubot-github-tfs --save
- Then add hubot-github-tfs to your external-scripts.json:
``json`
[
"hubot-github-tfs"
]
- Set the following environment variables in the shell where Hubot is running
| Variable | Required/Optional | Comments |
|----------|---------|----------|
|HUBOT_TFS_SERVER|required|Ip or DNS name of the TFS server|
|HUBOT_TFS_USERNAME|required|TFS username|
|HUBOT_TFS_PASSWORD|required|Password of the TFS user|
|HUBOT_TFS_GITHUB_PAT|optional|Personal Access Token of the GitHub user with repo:status permission. This will be used to update the pull request status.|
|HUBOT_TFS_PROTOCOL|optional|default to https|80
|HUBOT_TFS_PORT|optional|default to for http and 443 for https|/
|HUBOT_TFS_URL_PREFIX|optional|default to |defaultcollection
|HUBOT_TFS_DEFAULT_COLLECTION|optional|default to |
- Create a webhook on your GitHub repo for the Push event with the following URL :
``
http://
- Create a webhook on TFS with the following URL so Hubot can receive the notification back
``
http://
- Make sure the IIS server running TFS as basic authentication enabled.
#### Get some help
``
user1>> hubot tfs-build help
hubot>>Here's what I can do with TFS builds :
tfs-build list builds for
tfs-build list builds for
tfs-build queue
tfs-build queue
tfs-build list definitions for
tfs-build list definitions for
tfs-build rem all
tfs-build rem about
tfs-build forget about
tfs-build rem
tfs-build rem
#### List builds
`
user1>> hubot tfs-build list builds for SpidersFromMars
hubot>>
----------------------------------------------------------------------------------------
| Build | Status | Result | Branch | Definition |
----------------------------------------------------------------------------------------
|20160407.2 |completed |succeeded|master |SpidersFromMars on github.com |
|20160407.1 |completed |failed |master |SpidersFromMars on github.com |
|20160331.19 |completed |succeeded|master |SpidersFromMars on Octodemo |
|20160331.18 |completed |failed |master |SpidersFromMars on Octodemo |
|20160331.17 |completed |succeeded|syntaxerror |SpidersFromMars on Octodemo |
|20160331.16 |completed |failed |synataxerror |SpidersFromMars on Octodemo |
----------------------------------------------------------------------------------------
`
#### List build definitions for a project
``
user1>> hubot tfs-build list definitions for SpidersFromMars
hubot>> Found 1 results for SpidersFromMars in
hubot>>
--------------------------------------
| ID | Name |
--------------------------------------
|1 |SpidersFromMars on Octodemo |
--------------------------------------
#### Remind me which build definition is used to automatically trigger the build of a repository
``
user1>> hubot tfs-build rem about OctoCheese/SpidersFromMars
hubot>> OctoCheese/SpidersFromMars builds with defaultcollection/SpidersFromMars/1
#### Automatically build in TFS following a push in GitHub
``
user1>> hubot tfs-build rem OctoCheese/SpidersFromMars builds with SpidersFromMars/1
hubot>> Saved build setting for SpidersFromMars. Now building with defaultcollection/SpidersFromMars/1`
Note : The build definition id 1` was retrieved with the `list definitions` command
Whenever a push happens on this repo, Hubot will comment in the room specified in the webhook URL and trigger the registered build.
```
hubot>> @helaili just pushed code on OctoCheese/SpidersFromMars/testTFS. Requesting a TFS build with defaultcollection/SpidersFromMars/1