Hi,
I'm a newbie with Bitbucket. I used the default style of Bitbucket when integrating Bitbucket to Slack. I'm getting stuck in customizing the styles of notification when the Bitbucket pushing events messages to Slack channel. How could I customize it? I found Bitbucket has the Slack-notify pipe to customize but I want more as own badge, own icon, ...
Thanks
Hi @Châu Nguyễn Trung ,
Thank you for your question!
We provided atlassian/slack-notify pipe where you could modify
- pipe: atlassian/slack-notify:1.0.2 variables: WEBHOOK_URL: '<string>' PRETEXT: '<string>' MESSAGE: '<string>' # DEBUG: '<boolean>' # Optional.
Cheers,
Oleksandr Kyrdan
Hi @Châu Nguyễn Trung ,
Now Flexible payload supported in atlassian/slack-notify:1.2.0:
script: - envsubst < "payload.json.template" > "payload.json" - pipe: atlassian/slack-notify:1.2.0 variables: WEBHOOK_URL: $WEBHOOK_URL PAYLOAD_FILE: payload.json
Use custom payload created with Slack Block Kit and modify payload with the envsubst program that substitutes the values of environment variables.
Cheers,
Oleksandr Kyrdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But how do we get the environment variables into the script so that `envsubst` has access to them? I've tried everything I can think of, and read all the docs I can find, and very few ENV variables have values.
Please give an example of a fully custom environment variable.
For example, if I want a work log like this:
- export WORK_LOG=`git log --pretty=format:"%h%x09%an%x09%ad%x09%s" "$BITBUCKET_COMMIT^..$BITBUCKET_COMMIT" | tail -n +2`
How can I get that `$WORK_LOG` variable into a payload or `MESSAGE`.
This is one of the most frustrating things I've ever worked with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your question!
If you want substitutes the value of environment variable $WORK_LOG into payload file, you should have template file, i.e. payload.json.template
with name of the variable you want to invoke "$WORK_LOG"
after command executed
envsubst < "payload.json.template" > "payload.json"
you will have a new generated file "payload.json" with value of the "$WORK_LOG" variable.
Good example of envsubst here and file .
Best regards,
Oleksandr Kyrdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.