1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-26 06:23:37 +00:00

This patch splits send-to-channel-slack task from the slackmessage directroy

Changes include:
  - moves send-to-channel-slack task to the task directory
  - copies and modifies readme from slackmessage to send-to-channel-slack
  - copies owners file from slackmessage

Issue: #386

Signed-off-by: Puneet Punamiya <ppunamiy@redhat.com>
This commit is contained in:
PuneetPunamiya 2020-07-03 14:57:41 +05:30 committed by tekton-robot
parent 51e52b8ae0
commit 9c8214f888
3 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,7 @@
approvers:
- akihikokuroda
- ncskier
reviewers:
- akihikokuroda
- ncskier

View File

@ -0,0 +1,65 @@
# Post a message to slack
These tasks post a simple message to a slack channel. There are multiple ways to send
a message to slack. Each task here uses different method.
# send-to-channel-slack
This task uses chat.postMessage slack REST api to send the message.
Follow instructions [here](https://api.slack.com/messaging/sending) to obtain the OAuth access token for the bot app with `chat:write` scope.
The app must join the channel before the message posted by this task run. (invite the app in the channel)
## Install the Task and create a secret
```
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/send-to-channel-slack/0.1/send-to-channel-slack.yaml
```
Create a secret that has the OAuth token of the bot app.
Example token-secret.yaml
```
kind: Secret
apiVersion: v1
metadata:
name: token-secret
stringData:
token: {OAuth token for the bot app}
```
Example kubectl command
```
kubectl apply -f token-secret.yaml
```
## Inputs
### Parameters
* **token-secret**: The name of the secret that has the OAuth token. The key for the OAuth-token is token
* **channel**: [channel id](https://api.slack.com/messaging/retrieving#finding_conversation) or channel name where the message is posted
* **message**: Plain text message to be posted in the slack channel
## Usage
This TaskRun runs the Task to post a message to the channel.
```
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: run-send-to-channel-slack
spec:
params:
- name: token-secret
value: token-secret
- name: channel
value: {CHANNEL ID}
- name: message
value: "Hello from Tekton!"
taskRef:
name: send-to-channel-slack
```