如何在Office365Connector的Jenkins管道webhook中添加备注,提交者和开发者

问题描述

我已经在类似这样的管道中设置了office365Connector。如何添加像 由SCM更改启动或由用户SoAndSo。启动。 以及如何添加提交者和开发者。.

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"
        )
    }

}

解决方法

如果您要@提及某个人,jenkins的office365插件仍然无法使用该功能

要获取开始构建的用户,请参阅此answer

要获取提交者的电子邮件,请参阅此answer

如果像我一样真的要提及用户,则可以:

  • 如果您知道Java,请创建一个可以解决此issue在官方仓库上的问题的公关

  • 如果您不懂Java或无法节省时间,则必须一起破解:

  1. 这是您在管道中使用curl的方式

  2. 现在您必须让用户来自User graph api

  3. 将webhook添加为jenkins的凭证,如下所示: enter image description here

因此您可以在管道中调用它:

office365ConnectorSend message: "Hello",webhookUrl: credentials("wh-msteams-dev")
  1. 发送adaptive card,这是目前唯一支持提及的类型,这是文档中的示例:
{
  "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"
          }
        }
      ]
    }
  }
}

不,这不是小事。

是的,我也为这个提法的实现而感到痛苦。

很失望,但并不感到惊讶。毕竟这是 Microsoft 团队。

请继续。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...