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

Sending notifications to Microsoft Teams for Jenkins. [hostname in certificate didn't match] error

我在工作中发送工作通知时遇到问题,这里我使用公司的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
                }

但在 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",
                factDefinitions: [[name: "message", template: "Sucess: Deploy em $DEPLOY_STAGE de $REPO"],
                                  [name: "status", template: "Sucesso"]],
                color: "#00FF00",
                status: "Success"

        sh("curl -v --location --request POST '$WEB_HOOK_URL' --header 'Content-Type: application/json' --data-raw '{\"@type\": \"MessageCard\",\"@context\": \"http://schema.org/extensions\",\"themeColor\": \"#00FF00\",\"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/GreenThumbUP.png\",\"facts\": [{\"name\": \"Message\",\"value\": \"Sucesso: Deploy em $DEPLOY_STAGE de $REPO\"}, {\"name\": \"Status\",\"value\": \"Success\"},{\"name\": \"Job\",\"value\": \"${JOB_NAME}:${BUILD_NUMBER}\"}],\"markdown\": true}],\"potentialAction\": [{\"@type\": \"OpenUri\",\"name\": \"Abrir Build\",\"targets\": [{ \"os\": \"default\", \"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/ was changed to https://outlook.office.com/webhook 并且有效