微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

向 Microsoft Teams for Jenkins 发送通知 [证书中的主机名不匹配] 错误

如何解决向 Microsoft Teams for Jenkins 发送通知 [证书中的主机名不匹配] 错误

我在工作中发送工作通知时遇到问题,这里我使用了公司的 VPN 和防火墙。作业运行成功,可以在日志中看到连接器已激活,但未发送通知。 如果您对消息使用手动卷曲,它会正常工作

 script {
                    final String url = "webhook"

                    final String response = sh(script: "curl -X POST -H 'Content-type:application/json' --data '{\"text\":\"Message sent by jenkins\"}' webhook",returnStdout: true).trim()

                    echo response
                }

enter image description here

但 Jenkins 以自动方式无法正常工作

关注 Office 365 管道的一部分:

post {
      failure {
        office365ConnectorSend webhookUrl: "$WEB_HOOK_URL",factDeFinitions: [[name: "message",template: "Falha: Deploy em $DEPLOY_STAGE de $REPO"],[name: "status",template: "Falha"]],color: "#FF0000",status: "Failure"

        sh("curl -v --location --request POST '$WEB_HOOK_URL' --header 'Content-Type: application/json' --data-raw '{\"@type\": \"MessageCard\",\"@context\": \"http://schema.org/extensions\",\"themeColor\": \"#FF0000\",\"summary\": \"Teste de Mensagens EndPoint Jenkins\",\"sections\": [{\"activityTitle\": \"Jenkins avisa!\",\"activitySubtitle\": \"Resultado do build\",\"activityImage\": \"https://ac-buckets-dev-acpublicmedia-2cxkd4j0deg1.s3.amazonaws.com/icons/RedDownArrow.png\",\"facts\": [{\"name\": \"Message\",\"value\": \"FALHA: Deploy em $DEPLOY_STAGE de $REPO\"},{\"name\": \"Status\",\"value\": \"Failure\"},{\"name\": \"Job\",\"value\": \"${JOB_NAME}:${BUILD_NUMBER}\"}],\"markdown\": true}],\"potentialAction\": [{\"@type\": \"OpenUri\",\"name\": \"Abrir Build\",\"targets\": [{ \"os\": \"default\",\"uri\": \"${BUILD_URL}\" }]}]}'")
      }
      success {
        office365ConnectorSend webhookUrl: "$WEB_HOOK_URL",template: "Sucess: Deploy em $DEPLOY_STAGE de $REPO"],template: "Sucesso"]],color: "#00FF00",status: "Success"

        sh("curl -v --location --request POST '$WEB_HOOK_URL' --header 'Content-Type: application/json' --data-raw '{\"@type\": \"MessageCard\",\"themeColor\": \"#00FF00\",\"activityImage\": \"https://ac-buckets-dev-acpublicmedia-2cxkd4j0deg1.s3.amazonaws.com/icons/GreenThumbUP.png\",\"value\": \"Sucesso: Deploy em $DEPLOY_STAGE de $REPO\"},\"value\": \"Success\"},\"uri\": \"${BUILD_URL}\" }]}]}'")
      }
    }

日志:

[Office365connector] Failed to post data to webhook - webhook
    javax.net.ssl.SSLException: hostname in certificate didn't match: <> != </*.clo.footprintdns.com/*.hotmail.com/*.internal.outlook.com/*.live.com/*.nrb.footprintdns.com/*.office.com/*.office365.com/*.outlook.com/*.outlook.office365.com/attachment.outlook.live.net/attachment.outlook.office.net/attachment.outlook.officeppe.net/attachments.office.net/attachments-sdf.office.net/ccs.login.microsoftonline.com/ccs-sdf.login.microsoftonline.com/hotmail.com/mail.services.live.com/office365.com/outlook.com/outlook.office.com/substrate.office.com/substrate-sdf.office.com/outlook.com>
        at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.verifyHostName(SSLProtocolSocketFactory.java:339)
        at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.verifyHostName(SSLProtocolSocketFactory.java:275)
        at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.verifyHostName(SSLProtocolSocketFactory.java:258)
        at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:167)
        at org.apache.commons.httpclient.httpconnection.open(httpconnection.java:714)
        at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:394)
        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:178)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:404)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:330)
        at jenkins.plugins.office365connector.HttpWorker.run(HttpWorker.java:83)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

我该如何解决这个问题?

解决方法

webhook 服务器 https://compasso.webhook.office.com/ 已更改为 https://outlook.office.com/webhook 并且可以正常工作

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?