Hello,
i am using the slack/slack@1.0.4 orb. i am trying to use the only_for_branch parameter, and feed it multiple branches like this
- slack/status:
fail_only: 'true'
#mentions: 'USERID1,USERID2'
only_for_branch: |
hotfix
master
defect/fix-ci-build
webhook: ${SLACK_WEBHOOK}
However the above doesn’t work and i can only get it to work with a single string like:
only_for_branch: defect/fix-ci-build
is there a way to define multiple strings for the only_for_branch parameter?
Mats
rose
June 3, 2019, 9:09pm
2
@mathews Currently, that parameter is doing an exact check under the hood, so only designed to accept a single branch value :
only_for_branch:
description: If set, a specific branch for which slack status updates will be sent.
type: string
default: ""
if [ -z "$BASH" ]; then
echo Bash not installed.
exit 1
fi
- run:
name: Slack - Sending Status Alert
shell: /bin/bash
when: always
command: |
if [ "x" == "x<< parameters.only_for_branch>>" ] || [ "${CIRCLE_BRANCH}" == "<< parameters.only_for_branch>>" ]; then
# Provide error if no webhook is set and error. Otherwise continue
if [ -z "<< parameters.webhook >>" ]; then
echo "NO SLACK WEBHOOK SET"
echo "Please input your SLACK_WEBHOOK value either in the settings for this project, or as a parameter for this orb."
exit 1
else
#Create Members string
if [ -n "<< parameters.mentions >>" ]; then
IFS="," read -ra SLACK_MEMBERS \<<< "<< parameters.mentions >>"
for i in "${SLACK_MEMBERS[@]}"; do
That said, it should be pretty easy to modify it to do some kind of expanded check that would allow folks to pass either multiple exact branch names, or a regular expression pattern, etc.—feel free to take a shot at a PR .
Or, if that feels overburdensome/out-of-reach, you’re welcome to just file an issue against the repository and we can pull it onto our bugs/enhancements board for prioritization.
I’m sure you’re not the only one who would benefit from this functionality!
it looks like slack-orb: clir/slack-orb@0.0.6
already has this logic.
Thanks i will use this orb
rose
June 3, 2019, 10:23pm
4
Oh, awesome, great find! @mathews
That code is super simple, we’ll just borrow it and add it to our first-party Slack orb
rose
June 3, 2019, 11:01pm
5
@mathews Now available (along with a lot of other features not included in clir/slack
) in circleci/slack@3.2.0
1 Like
system
Closed
June 13, 2019, 11:01pm
6
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.