Multiline Field in Slack Message

I want to add a multi-line field to the slack message, but I’m having trouble with the format.
Only the first line of the Release Notes field is visible. Slack step and output is as follows:

- slack@3:
    inputs:
      - webhook_url: $SLACK_URL
      - channel: '#app-releases'
      - title: ''
      - message: ''
      - author_name: ''
      - pretext: ''
      - text: ''
      - fields: |-
          Release Notes|-Fix build issue
          -Update app icon
          App|${BITRISE_APP_TITLE}
          Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
          Git Branch|${BITRISE_GIT_BRANCH}
          Git Author|${GIT_CLONE_COMMIT_AUTHOR_NAME}
          Git Commit|${GIT_CLONE_COMMIT_MESSAGE_SUBJECT}
          Git Commit Hash|${GIT_CLONE_COMMIT_HASH:0:7}

So I tried with ‘\n’ as below but this method doesn’t seem to work either.

- slack@3:
    inputs:
      - webhook_url: $SLACK_URL
      - channel: '#app-releases'
      - title: ''
      - message: ''
      - author_name: ''
      - pretext: ''
      - text: ''
      - fields: |-
          Release Notes|-Fix build issue\n-Update app icon
          App|${BITRISE_APP_TITLE}
          Workflow|${BITRISE_TRIGGERED_WORKFLOW_ID}
          Git Branch|${BITRISE_GIT_BRANCH}
          Git Author|${GIT_CLONE_COMMIT_AUTHOR_NAME}
          Git Commit|${GIT_CLONE_COMMIT_MESSAGE_SUBJECT}
          Git Commit Hash|${GIT_CLONE_COMMIT_HASH:0:7}

I’ve read the links below but couldn’t find the solution. What method should I use for the correct format?

Try adding ‘\n’ for new lines in the text field, the fields are single line only I believe

If you want additional text use the text field instead of the fields input

  • text:
  • fields:

See: Creating rich message layouts | Slack

I mentioned that I already added ‘\n’ but it’s not working. Do you mean something different?

fields are single line and do not support “\n”
text supports multiline “\n”

image

No, Slack supports multi-line fields. I tried it with Slack webhook and it works.

I ran some tests and confirmed what you observed.

Here is a PR to solve the issue, nice catch!

You can test this fork step by using this in your bitrise.yml by replacing the - slack@3: with

- git::https://github.com/DamienBitrise/steps-slack-message@master:

Here is a working example from my test where the field is

- fields: |
    App|${BITRISE_APP_TITLE}\nline 2

image

It works like a charm. Thank you very much

1 Like

@dorukkangal Release Slack Step version 3.5.0 that contains this feature. (Release 3.5.0 · bitrise-steplib/steps-slack-message · GitHub)

2 Likes

Thanks for letting me know. I’m looking forward to it.