Skip to content

Instantly share code, notes, and snippets.

@kiichi
Last active June 11, 2018 09:39
Show Gist options
  • Select an option

  • Save kiichi/938ea910f88bf43b0db1 to your computer and use it in GitHub Desktop.

Select an option

Save kiichi/938ea910f88bf43b0db1 to your computer and use it in GitHub Desktop.
Postman and Newman Integration with Slack
#This is script to run postman unittest from CLI
#Send the results to Slack
#by Kiichi
#[Instructions]
#In slack, create incoming webhook integration, and grab the url
#Create a complete postman unittest and environment then export it to a directory
#Make sure install node and newman.
#Save this script and give a permission, such as chmode +x unittest.sh
TMP="postman.out"
TMP2="postman.out2"
newman -c MyTest.json.postman_collection -e MyEnv.postman_environment -C > $TMP
# remove multibyte white spaces
sed 's/ / /g' $TMP > $TMP2
RESULTS=$(cat $TMP2 | while read line; do echo -n "$line\\n"; done)
curl -X POST --data-urlencode 'payload={"channel": "#general", "username": "postman", "text": "'"$RESULTS"'", "icon_emoji": ":postbox:"}' https://hooks.slack.com/services/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
rm -rf $TMP
rm -rf $TMP2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment