bitrise-steplib / steps-slack-message Goto Github PK
View Code? Open in Web Editor NEWSend a Slack message
License: MIT License
Send a Slack message
License: MIT License
If I leave field "Text of the message to send."
empty, the Slack step fails with error:
Error: failed to parse config:
- Message: required variable is not present
Thanks for creating this step.
In my workflow, i added this step twice. Once at the beginning of the build to indicate that the build started and once at the end to indicate the build is done.
On pull request build, every notification (start and end) are being sent twice to our channel.
I'm not even sure where to start looking for what I did wrong.
Note that on a scheduled build, that has the same two notification steps, the notifications are only sent once
here is yml:
pull_request:
steps:
- comment-on-github-pull-request:
inputs:
- body: Check $BITRISE_BUILD_URL for details
- personal_access_token: "$GITHUB_ACCESS_TOKEN"
envs:
- opts:
is_expand: false
FASTLANE_LANE: ios pullRequest
- opts:
is_expand: false
FASTLANE_WORK_DIR: ios
before_run:
- Get_Code_Configure_Stack
- code_quality
- fastlane_build
fastlane_build:
steps:
- slack:
inputs:
- channel: "#dev-code-events"
- text: 'A build just started on bitrise for branch $BITRISE_GIT_BRANCH '
- channel_on_error: "#dev-code-events"
- text_on_error: The build failed, please check why at $BITRISE_BUILD_URL
- webhook_url: "$MONKEE_SLACK"
- certificate-and-profile-installer: {}
- fastlane:
inputs:
- lane: "$FASTLANE_LANE"
- work_dir: "$FASTLANE_WORK_DIR"
- deploy-to-bitrise-io:
inputs:
- deploy_path: "./ios/$IPA_NAME.ipa"
- slack:
inputs:
- channel: "#dev-code-events"
- text: Build successful!
- channel_on_error: "#dev-code-events"
- text_on_error: The build failed, please check why at $BITRISE_BUILD_URL
- pretext: ''
- webhook_url: "$MONKEE_SLACK"
before_run: []
the workflow for the scheduled build:
iOS_daily:
envs:
- opts:
is_expand: false
FASTLANE_LANE: ios daily
- opts:
is_expand: false
FASTLANE_WORK_DIR: ios
before_run:
- Get_Code_Configure_Stack
- code_quality
- fastlane_build
In case of success build, I want to send a message to channel #abc
not tagging anyone.
However, in case of failure, I want to send a message to the same channel, tagging @here
or @someguy
.
I've tried all of the following with version 2.7.3:
The following instructions is very confusing:
What are those *
characters, am I supposed to include them?
Hi,
I've got 4 workflows and all of them will send to slack at the end. All works except one of them.
It always returned this error: Error: Both API Token and WebhookURL are empty. You need to provide one of them. If you want to use incoming webhooks provide the webhook url. If you want to use a bot to send a message provide the bot API token
When I take a look at the others, I found the settings are similar except for the text to be sent. Here's the slack settings of the failed workflow in the bitrise.yml.
- [email protected]:
inputs:
- text: 'QA test and build successful! Build number: #${BITRISE_BUILD_NUMBER}'
- text_on_error: 'QA test and build failed! Build number: #${BITRISE_BUILD_NUMBER}'
- fields: |
App|${BITRISE_APP_TITLE}
Branch|${BITRISE_GIT_BRANCH}
Commit|${GIT_CLONE_COMMIT_MESSAGE_SUBJECT} (${GIT_CLONE_COMMIT_HASH})
Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
- webhook_url: "$SLACK_WEBHOOK_URL_IOS"
I tried to change it to use API token instead of webhook like this but it still failed.
- [email protected]:
inputs:
- text: 'QA test and build successful! Build number: #${BITRISE_BUILD_NUMBER}'
- text_on_error: 'QA test and build failed! Build number: #${BITRISE_BUILD_NUMBER}'
- fields: |
App|${BITRISE_APP_TITLE}
Branch|${BITRISE_GIT_BRANCH}
Commit|${GIT_CLONE_COMMIT_MESSAGE_SUBJECT} (${GIT_CLONE_COMMIT_HASH})
Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
- api_token: "$SLACK_API_TOKEN"
- channel: "#kolabree-build-ios"
- webhook_url: ''
Here are the settings of the successful ones:
- [email protected]:
inputs:
- text: 'Branch "${BITRISE_GIT_BRANCH}" test successful! Build number: #${BITRISE_BUILD_NUMBER}'
- emoji: ''
- text_on_error: 'Branch "${BITRISE_GIT_BRANCH}" test failed! Build number:
#${BITRISE_BUILD_NUMBER}'
- fields: "App|${BITRISE_APP_TITLE}\nBranch|${BITRISE_GIT_BRANCH} \nCommit|${GIT_CLONE_COMMIT_MESSAGE_SUBJECT}
(${GIT_CLONE_COMMIT_HASH})\nWorkflow|${BITRISE_TRIGGERED_WORKFLOW_ID}\n"
- webhook_url: "$SLACK_WEBHOOK_URL_IOS"
- [email protected]:
inputs:
- text: 'Beta (Testflight) test and build successful! Build number: #${BITRISE_BUILD_NUMBER}'
- text_on_error: 'Beta (Testflight) test and build failed! Build number: #${BITRISE_BUILD_NUMBER}'
- fields: |
App|${BITRISE_APP_TITLE}
Branch|${BITRISE_GIT_BRANCH}
Commit|${GIT_CLONE_COMMIT_MESSAGE_SUBJECT} (${GIT_CLONE_COMMIT_HASH})
Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
- webhook_url: "$SLACK_WEBHOOK_URL"
Both these test-branch and beta workflows can send to Slack. And if you read the settings, they are similar. Where did I do wrong here? How do I fix this?
Thanks.
I would like to have my Slack notification go to multiple recipients (channels and/or users).
Can the channel*
fields be refactored to accept a list of notification targets? E.g. #build_results, $SLACK_LAST_COMMITTER, @qa
(assuming SLACK_LAST_COMMITTER
is an environment variable I exported in a previous step)?
The implementation could simply to loop over this collection and send a copy of the same message to each target.
Thanks!
When registering only the error channel and leave the success channel empty, the build success is sent to the error channel.
- slack:
inputs:
- channel: ""
- channel_on_error: "#my_channel_error"
- webhook_url: "$my_url"
Hi,
Are there any plans to support postMessage api with token?
Instead of working with a webhook. Now I need to create a webhook for every channel I want to post to. Because you can't overwrite the channel param anymore.
Friendly regards,
Seppe
Would it be possible to make more information available on the message, such as
?
Hello guys, I am working with bitrise and I am using this awesome step to publish messages for Slack and I did use it in the past without troubles with webhooks.
Unfortunately it is not working and I don't know why.
I have enabled debug mode and it prints a this JSON:
�[33;1mBoth API Token and WebhookURL is provided. Using the webhook url�[0m
Request to Slack: {"channel":"#dev_notifications","text":"New version available. https://play.google.com/apps/internaltest/4701449134258367556","attachments":[{"fallback":"I forgot the trending json\n\nSee merge request 2ourista/hipjaunt-mobile-react-native!11","color":"#3bc3a3","pretext":"*Build Succeeded!*","author_name":"Franco Cerrutti","title":"Merge branch 'json_correction' into 'development'","text":"I forgot the trending json\n\nSee merge request 2ourista/hipjaunt-mobile-react-native!11","fields":[{"short":true,"title":"App","value":"hipjaunt-mobile-react-native"},{"short":true,"title":"Branch","value":"development"},{"short":true,"title":"Workflow","value":"test"}],"footer":"Bitrise","footer_icon":"https://github.com/bitrise-io.png?size=16","ts":1545419874,"actions":[{"style":"default","text":"View App","type":"button","url":"https://app.bitrise.io/app/991509aa7853b590"},{"style":"default","text":"View Build","type":"button","url":"https://app.bitrise.io/build/c98a67e551f979f0"}]}],"icon_url":"https://github.com/bitrise-io.png","link_names":true,"username":"Bitrise"}
�[32;1m
Slack message successfully sent! 🚀
�[0m
|
But if I copy that Json into the POSTMAN with the same webhook URL it works like charm, so I guess that is from your side or there is something I am doing wrong.
Thanks for your support.
Cheers!
We are using this step in a workflow to run unit tests for our app. We would like this step to run only when there was an issue with the test so that we don't flood our Slack channel with "Success!" messages. Would it be possible to skip grabbing the message
variable if the build failed?
We want to use this slack step in our Bitrise workflow. we want to attach a link of the first failed test in "- fields: ", how can we do it?
Hi, How to share a text as a code block?
I tried triple backticks (```) into Text of the message to send section but It didn't work.
https://slack.com/intl/en-tr/help/articles/202288908-Format-your-messages
My team would love to see an option to skip sending a message for aborted builds. As it stands, we often get put on alert when our main
branch reports a build failed, only to look closer and see the build was actually aborted due to our rolling builds rule.
The slack step is great and very flexible but I'm missing one functionality though. Most of the inputs can be defined seperately for succesful and failed builds. However, that is not true for channel. In other words: I want to send a message to a certain channel for succesful builds and to a different channel for failed builds.
Thanks!
E.g. wrong webhook URL which responds with 200 (example: a requestb.in which always responds with 200) but actually is not the Slack Incoming Webhook you want.
I'm using the Install page QR code step along with the slack message step but when I send the link to Slack, I'm seeing the QR code image but I don't want to show the image I just want to share the link without showing that image in slack.
Hi guys,
Thanks for this cool step! :D
We were using it in its 2.1.0 version and were able to send gifs on succesful/failed builds.
Unfortunately, when updating to 2.3.0, the gifs do not unfold anymore :(
See below the difference: the two first messages were sent with 2.3.0 version of the step, and the two last with version 2.1.0. A green line has also been added in the body of the message (probably the cause of this :))
This integration is very helpful for me but I have one problem.
I would like to work together bitrise and bots in Slack.
However, this integration can have text only in attachments, so bots cannot respond to commands from bitrise.
Sending plain text, not in attachments makes very easy to do such cooperation.
Hi,
I've been using the slack step with incoming web hooks.
So far it was working properly, until the 3.0.0 release where the step requires an API token.
How can I generate an API token that i can use instead of the web hook?
Good day ,
The table inside the attachment is not showing button for Install Map, the env variable BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP was populated correctly in a previous step "Deploy to bitrise"
This is my configuration for the slack step for the list of buttons:
You probably noticed that I also put the BITRISE_PUBLIC_INSTALL_PAGE_URL_MAP in the table inside the attachments, I did this on purpose because I just figure out that if I put this I get the contents of this variable as a BLOB text. But this is totally non user/QA/tester friendly
This is my Build URL: https://www.bitrise.io/build/c55b1d0497d39346 as requested in https://github.com/bitrise-io/steps-deploy-to-bitrise-io/issues/59
If you do not specify a channel in the step, it fails. The webhook URL contains the channel it's supposed to post to already.
https://github.com/bitrise-steplib/steps-slack-message/blob/master/main.go#L76
When there is leading or trailing whitespace in the input field for Channel it is not removed
For example I'd like to have nightlies, and expect them to suceed 99% of the time, no need to spam my channel each night. But I'd like to be notified when the build fails. So I would love to have this step send message only on build status being different then the last one.
Yesterday, I realized that my Slack notifications weren't working anymore. Despite changing nothing, I started getting this error:
Error: Both API Token and WebhookURL is empty. You need to provide one of them. If you want to use incoming webhooks provide the webhook url. I you want to use a bot to send a message provide the bot API token
After a lot of debugging, I wasn't able to determine why the workflow step thought that the webhook URL was empty. I then switched the webhook URL with a bot token, and that worked once, so I thought I was set. Here's my new config:
- slack:
inputs:
- api_token: "$SLACK_BOT_TOKEN"
Today, it stopped working again. I can't figure out what's wrong.
From the day that bitrise was setup with Slack, we were able to receive messages on Slack on the channel that was selected(even though the channel was private). Even yesterday the messages were being sent.
And then today when Bitrise made a build today, it failed to push to slack. This was the message that was recieved:
Error: server error: 404 Not Found, response: channel_not_found
Is there any reasons why this would happen?
That would be really great to manage environnement variable in environnement variable for the message part.
For a better explanation, imagine:
Workflow name: 123
app:
envs:
- SLACK_MSG_START_WORKFLOW: '==== \n Start Workflow: $BITRISE_TRIGGERED_WORKFLOW_TITLE
\n ===='
opts:
is_expand: false
steps:
- slack:
title: Start Workflow
inputs:
- message: '$SLACK_MSG_START_WORKFLOW'
Actual version of the plugin display on Slack:
====
Start Workflow: $BITRISE_TRIGGERED_WORKFLOW_TITLE :rotating_light:
====
Instead of
====
Start Workflow: 123 :rotating_light:
====
When the step posts to Slack, #channel
and @user
aren't autolinked in the text of the message, presumably because the step doesn't instruct Slack to do it.
Could you add an option to enable link_names=1
in the Webhook request?
Hi there,
Trying to send builds do our slack but it fails with the error in the title. I have obfuscated a bit the urls but I can provide them if really needed.
Thanks for any help
INFO[23:34:00] Start installing (golang) with apt-get
INFO[23:34:00] * [OK] Step dependency (go) installed, available.
Config:
When the step posts to Slack, the step could export an env variable of the message ts
.
Later in a build another step posting to Slack could specify a thread_ts
field with the exported ts
from the first message. Hence subsequent messages within a single build all post into a message thread with updates.
Use case would be, e.g.
When multiple users are collaborating, the above can get really messy and out of order. Threads would be useful to group each build's status messages together neatly and easily
It would be nice if we could send an attachment together with the message. Maybe somebody wants to send the APK directly in the message or you could generate a QR code for the install page and include that one as attachment.
Hi! Not sure if I'm using this incorrectly, but my Slack step includes for example @gobetti
in the message field, the option "linkify names" has the default value (yes) and still, the messages being posted to Slack have a plain text rather than a link to my Slack user.
This happens to any of our users so it's not a problem specific with my Slack account.
This also happens in all of the positions I tried to place the tag (message
, text
, author_name
and title
).
I took a look at this feature's implementation and couldn't find anything that could justify this behavior, it looks like this linking is actually made by Slack and you're following Slack's instructions to format messages, is that right? #22
Let me know please if this is known to be an issue with Slack currently, or if I have it incorrectly configured. Thank you!
It would be cool if the step is able to send a message to #dev_channel in case the build fails, and #qa_channel if build is success
Hi,
It's been a time since I've been receiving this error message:
Error: Both API Token and WebhookURL are empty. You need to provide one of them. If you want to use incoming webhooks provide the webhook url. If you want to use a bot to send a message provide the bot API token
I do have a Webhook URL (not an API token). Even more, it does not always fails, but most of times.
Thanks!
I get this log message:
Slack message successfully sent! 🚀 | | +---+---------------------------------------------------------------+----------+ | ✓ | [email protected] | 5.78 sec | +---+---------------------------------------------------------------+----------+
but I don't receive any message, how can I see all logs to try to find the error. My version slack is 2.6.2 this could be a problem?
It's sending messages on success to the channel declared in on failure. My use case is that I only want to see a slack message if the build fails and not on success. Using the latest version.
Slack token is leaking on version: 2.7.3
of the step.
😭
We're trying to make the build step post a slack message as a thread to a previous message. The previous message is supposed to export a timestamp for it's message to the "name" variable of the thread TS. This however produces an error.
+------------------------------------------------------------------------------+| (9) Send a Slack message |
+------------------------------------------------------------------------------+
| id: slack |
| version: 3.5.0 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: go |
| time: 2023-04-07T13:30:42Z |
+------------------------------------------------------------------------------+
| |
Config:
The newly created thread timestamp environment variable name
Hello,
I've customised the action buttons on the step to add a link to the PR but it only appears when build succeed and not during a failure. I couldn't find a setting on the step to customise the buttons in case of failure so I guess it should be working the same whether it's a success or a failure ?
My yaml code :
- slack@3:
inputs:
- channel: "#mobile-ci-status"
- text: ":white_check_mark: Congratulation! Your build for :android: has succeeded! "
- emoji: ''
- text_on_error: ":x: Sorry... Your build for :android: has failed... "
- emoji_on_error: ''
- buttons: |
View App|${BITRISE_APP_URL}
View Build|${BITRISE_BUILD_URL}
View PR|${GITHUB_PR_LINK}
- webhook_url: "$slackWebhook"
The result on success is good with the three buttons :
But when it's an error the view PR disappears :
Is there something i'm missing during the setting of the step ?
Thank you in advance for your response and Merry Christmas 🙏
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.