1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-22 06:02:51 +00:00
catalog/task/send-to-channel-slack/0.1
PuneetPunamiya 9c8214f888 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>
2020-07-13 13:41:58 +01:00
..
OWNERS This patch splits send-to-channel-slack task from the slackmessage directroy 2020-07-13 13:41:58 +01:00
README.md This patch splits send-to-channel-slack task from the slackmessage directroy 2020-07-13 13:41:58 +01:00
send-to-channel-slack.yaml This patch splits send-to-channel-slack task from the slackmessage directroy 2020-07-13 13:41:58 +01:00

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 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 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