function SendMessageToDingding()
{
  curl https://oapi.dingtalk.com/robot/send?access_token=1234567890 \
   -H 'Content-Type: application/json' \
   -d "
  {\"msgtype\": \"text\", 
    \"text\": {
        \"content\": \"余额\naccount_balances_amount  不足 \nAMOUNT_LOW \"
     },
     \"at\": {
        \"atMobiles\": \"["123456"]\",
        \"isAtAll\": \"false\"
     }
  }"
}
SendMessageToDingding 

1 对 “shell调用钉钉告警 变量处理”的想法;

  1. function SendMessageToDingding_Success()
    {
    curl https://oapi.dingtalk.com/robot/send?access_token=b8f750930c493ea6558be3095e67de156dfcf83ec84a3cda7188aae6f62cd575 \
        -H 'Content-Type: application/json' -d  \
        "{\"msgtype\": \"text\", 
            \"text\": {
                \"content\": \"环境:生产\n发布状态:成功\n镜像版本:{APP_NAME}:{currentTimeStamp}\n分支:{branch}\n执行人:{BUILD_USER}\n执行时间:{Date}\n \"
            },
            \"at\": {
            \"atMobiles\": \"["15010300473"]\",
            \"isAtAll\": \"true\"
         }
        }"
    }
    
    function SendMessageToDingding_Faild()
    {
    curl https://oapi.dingtalk.com/robot/send?access_token=b8f750930c493ea6558be3095e67de156dfcf83ec84a3cda7188aae6f62cd575 \
        -H 'Content-Type: application/json' -d  \
        "{\"msgtype\": \"text\",        \"text\": {
                \"content\": \"环境:生产\n发布状态:失败\n镜像版本:{APP_NAME}:{currentTimeStamp}\n分支:{branch}\n执行人:{BUILD_USER}\n执行时间:{Date}\n \"
            },
            \"at\": {
            \"atMobiles\": \"["15010300473"]\",
            \"isAtAll\": \"true\"
         }
        }"
    }
    if [ $? = 0 ];then
    SendMessageToDingding_Success
    else
    SendMessageToDingding_Faild
    fi
    

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code