Sending notification to Microsoft Teams by Jenkins. [hostname in Certificate didn’t match]

Asked

Viewed 43 times

0

I have a problem sending job notification at work, here I use the company’s VPN and firewall. Job has been run successfully and it is possible to check in the log that the connector has been activated, but the notification is not sent.

If I send a message by manual URL it works correctly

 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

But automated by Jenkins is not working

Follow the part of the Office 365 pipeline

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}\" }]}]}'")
      }
    }

Logs:

[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)

How can I solve this problem ?

2 answers

0


-3

Good afternoon Jackson
I had the same problem as yours. I was able to solve it with the Java update (actually replacing it with Openjdk). I needed to update the following plugins in Jenkins:

  • Office-365-Connector
  • token-macro
  • workflow-step-api

All done, notifications returned to appear normally on the Teams channel.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.