Choose slack template message depending on the result


#1

I’m new with Travis, I followed this tutorial (https://axdlog.com/2018/setting-up-slack-build-notification-in-travis-ci-for-github-project/) to be notified in Slack every time a PR is created or a pull is done.

So, here is what my .travis.yml looks like :

language: node_js
node_js:
  - 8
sudo: required
addons:
    chrome: stable
before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
install:
  - npm set progress=false
  - npm install
  - npm run electron:linux
script:
  - npm run test:e2e
notifications:
  email: false
  slack:
    rooms:
      - secure: [MY SECURE TOKEN]
    on_success: always
    on_failure: always
    template:
      - "Repo %{repository_slug} %{result} build (<%{build_url}|#%{build_number}>) for commit (<%{compare_url}|%{commit}>) on branch %{branch}."
      - "Execution time: %{duration}"
      - "Message: %{message}"

As you can see, I use the template of the tutorial. What I want now is to get the name of the people responsible of the build and manage different cases for each contexts : for exemple print “Well done @User, test passed” (where @User is the author) on success or “An error has occured” on error and “You failed” in the last case.
How can I personalize this template depending on the result ?

Thank you for your help ! :slight_smile: