This sample
sub-directory contains an EventListener and Pipeline definition that you can include in your Tekton pipeline configuration to run an example of the slack-post-message
task.
-
Create or update a Toolchain so it includes:
- a Slack integration
- the repository containing this tekton task
- a Tekton pipeline definition
-
Add the definitions of this task and the sample (
slack
andslack/sample
paths) -
Add the environment properties as needed:
domain
(optional) the Slack domain to send the message to.channel
(optional) the channel to post to (overrides the dafault channel as set in the Slack webhook).message-format
(optional) the format of the message (text or JSON).message-script
(optional) Shell script that provides messsage content.message
(optional) the message to post to Slack.
Note: when using JSON format, the message is posted as-is to Slack.
-
Create a manual trigger to start the sample listener
-
Run the pipeline
-
The message is posted to Slack
-
Optional: check the execution log
-
Optional: Create a message using snippet
a) Define the snippet in the
message-script
environment property of the pipelinemessage-script: `echo 'Message sent from PipelineRun' ${PIPELINE_RUN_NAME}; echo 'uid:' ${PIPELINE_RUN_ID}; echo 'buildNumber:' ${BUILD_NUMBER};`
Note: this could also be done in the trigger-template or pipeline definition
b) After running the pipeline, a new message like the following should have been posted to the Slack channel
c) Check the execution log