Forked from chusiang/teams-chat-post-for-workflows.sh
Created
March 23, 2020 07:27
-
-
Save curso007/f7dc95d1c66d55a35320cf7187ef0ca6 to your computer and use it in GitHub Desktop.
Revisions
-
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ # Help. if [[ "$1" == "-h" || "$1" == "--help" ]]; then echo 'Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>"' exit 0 fi # Webhook or Token. -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 14 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,21 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:04 # Description: Post a message to Microsoft Teams. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # # ============================================================================= # Help. if [[ "$1" == "-h" || "$1" == "--help" ]]; then echo 'Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>"' exit 1 fi # Webhook or Token. WEBHOOK_URL=$1 if [[ "${WEBHOOK_URL}" == "" ]] then @@ -22,7 +25,7 @@ then fi shift # Title . TITLE=$1 if [[ "${TITLE}" == "" ]] then @@ -31,7 +34,7 @@ then fi shift # Color. COLOR=$1 if [[ "${COLOR}" == "" ]] then @@ -40,17 +43,17 @@ then fi shift # Text. TEXT=$* if [[ "${TEXT}" == "" ]] then echo "No text specified." exit 1 fi # Convert formating. MESSAGE=$( echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g" ) JSON="{\"title\": \"${TITLE}\", \"themeColor\": \"${COLOR}\", \"text\": \"${MESSAGE}\" }" # Post to Microsoft Teams. curl -H "Content-Type: application/json" -d "${JSON}" "${WEBHOOK_URL}" -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #!/bin/sh # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:38 @@ -11,7 +11,7 @@ # # - https://gist.github.com/dopiaza/6449505#gistcomment-1627214 # # ============================================================================= # webhook & token. WEBHOOK_URL=$1 -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #!/bin/sh # ============================================================ # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:38 # Description: Post a message to Microsoft Teams. # # Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>" @@ -15,7 +15,7 @@ # webhook & token. WEBHOOK_URL=$1 if [[ "${WEBHOOK_URL}" == "" ]] then echo "No webhook_url specified." exit 1 @@ -24,7 +24,7 @@ shift # title . TITLE=$1 if [[ "${TITLE}" == "" ]] then echo "No title specified." exit 1 @@ -33,7 +33,7 @@ shift # color. COLOR=$1 if [[ "${COLOR}" == "" ]] then echo "No status specified." exit 1 @@ -42,15 +42,15 @@ shift # text. TEXT=$* if [[ "${TEXT}" == "" ]] then echo "No text specified." exit 1 fi # convert formating. MESSAGE=$( echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g" ) JSON="{\"title\": \"${TITLE}\", \"themeColor\": \"${COLOR}\", \"text\": \"${MESSAGE}\" }" # post to slack. curl -H "Content-Type: application/json" -d "${JSON}" "${WEBHOOK_URL}" -
chusiang created this gist
Mar 28, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #!/bin/bash # ============================================================ # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:04 # Description: Post a message to Microsoft Teams. # # Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>" # # Reference: # # - https://gist.github.com/dopiaza/6449505#gistcomment-1627214 # # ============================================================ # webhook & token. WEBHOOK_URL=$1 if [[ $WEBHOOK_URL == "" ]] then echo "No webhook_url specified." exit 1 fi shift # title . TITLE=$1 if [[ $TITLE == "" ]] then echo "No title specified." exit 1 fi shift # color. COLOR=$1 if [[ $COLOR == "" ]] then echo "No status specified." exit 1 fi shift # text. TEXT=$* if [[ $TEXT == "" ]] then echo "No text specified." exit 1 fi # convert formating. MESSAGE=$( echo $TEXT | sed 's/"/\"/g' | sed "s/'/\'/g" ) JSON="{\"title\": \"$TITLE\", \"themeColor\": \"$COLOR\", \"text\": \"$MESSAGE\" }" # post to slack. curl -H "Content-Type: application/json" -d "$JSON" "$WEBHOOK_URL"