You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.5 KiB

9 years ago
  1. # Matrix Notification Resource for Concourse CI
  2. Send notification messages to [Matrix](http://matrix.org) using a string message or templated message.
  3. This resource borrows heavily from the [Slack notification resource](https://github.com/cloudfoundry-community/slack-notification-resource). Usage and behavior around text and text_file parameters should be handled exactly the same as in that.
  4. ## Installing
  5. ```
  6. resource-types:
  7. - name: matrix-notification-resource
  8. type: docker-image
  9. source:
  10. repository: freelock/matrix-notification-resource
  11. ```
  12. ## Registering with Matrix
  13. This resource needs an access token for a valid user account. It will not create the user account for you, or retrieve the token.
  14. To get a token, first create a Matrix user account on your homeserver of choice. Then you can use Curl to get an access token for the account:
  15. ```
  16. curl -XPOST -d '{"type":"m.login.password", "user":"example", "password":"wordpass"}' "http://matrix.org/_matrix/client/api/r0/login"
  17. {
  18. "access_token": "QGV4YW1wbGU6bG9jYWxob3N0.vRDLTgxefmKWQEtgGd",
  19. "home_server": "matrix.org",
  20. "user_id": "@example:matrix.org"
  21. }
  22. ```
  23. ... add the returned access_token to the resource.
  24. Then, a user will need to invite the account to the appropriate room, and the account will need to accept the invitation.
  25. ## Source Configuration
  26. * `matrix_server_url`: *Required.* Example: https://matrix.org
  27. * `token`: *Required.* token to authenticate with Matrix server
  28. * `room_id`: *Required.* The room to send notifications to -- this account must already be a member of this room.
  29. Pull requests accepted for room_alias, user logins, auto-joins.
  30. #### `out`: Sends message to Matrix room
  31. Send message to specified Matrix Room, with the configured parameters
  32. #### Parameters
  33. * `text`: (string) Text to send to the Matrix room
  34. * `text_file`: (string) File containing text to send to the Matrix room
  35. * `msgtype`: *Optional.* Message type, m.notice, m.text (default: m.notice)
  36. ## Example
  37. ### Check
  38. ```
  39. ---
  40. resources:
  41. - name: matrix-notification
  42. type: matrix-notification-resource
  43. source:
  44. matrix_server_url: https://matrix.org
  45. token: {{matrix_token}}
  46. room_id: {{matrix_room_id}}
  47. ```
  48. ### In
  49. *Not supported*
  50. ### Out
  51. ```
  52. ---
  53. ---
  54. - put: matrix-notification
  55. params:
  56. text_file: results/message.txt
  57. text: |
  58. The build had a result. Check it out at:
  59. http://my.concourse.url/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
  60. or at:
  61. http://my.concourse.url/builds/$BUILD_ID
  62. Result: $TEXT_FILE_CONTENT
  63. ```