简体   繁体   中英

How can I add the Remarks, Committers and Developers in Jenkins pipeline webhook for office365Connector

I have set up the office365Connector in a pipeline like so.. How to add the auto Remarks like Started by an SCM change or Started by User SoAndSo.. and how to add the Committers and Developers..

post{
  success{
    office365ConnectorSend(
        status: "Build Success",
        webhookUrl: "Url",
        color: '00ff00',
        message: "Some Message"
        )  
      
    }
    failure{
         office365ConnectorSend(
        status: "Build Failed",
        webhookUrl: "UrL",
        color: 'ff4000',
        message: "The build has failed, please check build logs"
        )
    }

}

If you want to @mention someone, that's still not available by the office365 plugin for jenkins

To get the user that started the build, see this answer

To get the committer's email, see this answer

If you really want to mention users, as I do, you can:

  • if you know java, create a PR that solves this issue on the official repo

  • if you don't know java, or can't spare the time, you will have to hack things together:

  1. This is how you would use curl from a pipeline

  2. Now you have to get the user is from the User graph api

  3. Add the webhook as a credential on jenkins, like this: 在此处输入图片说明

So you can invoke it in the pipeline:

office365ConnectorSend message: "Hello", webhookUrl: credentials("wh-msteams-dev")
  1. Send an adaptive card , which is the only type that supports mentions at the moment, here's a sample from the docs:
{
  "contentType": "application/vnd.microsoft.card.adaptive",
  "content": {
    "type": "AdaptiveCard",
    "body": [
      {
        "type": "TextBlock",
        "text": "Hi <at>John Doe</at>"
      }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.0",
    "msteams": {
      "entities": [
        {
          "type": "mention",
          "text": "<at>John Doe</at>",
          "mentioned": {
            "id": "29:123124124124",
            "name": "John Doe"
          }
        }
      ]
    }
  }
}

No, this is not trivial.

Yes, I'm also in pain by how bad this mention is achieved.

Disappointed, but not surprised. This is Microsoft Teams after all.

Please surive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM