Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display build status with Section.activityImage instead of Card.themeColor #336

Open
AceOfSnakes opened this issue Feb 11, 2024 · 9 comments

Comments

@AceOfSnakes
Copy link

AceOfSnakes commented Feb 11, 2024

What feature do you want to see added?

Colleagues - what are you thinking about display status of the build in the Section.activityImage (missed for now) instead of Card.themeColor

Image source should be in format img src="data:image/png;base64; *****************************

where ************************* is a base64 of a image content - for CORS workaround in teams

teamz
blue
gray
green
red
yellow

Upstream changes

No response

Are you interested in contributing this feature?

No response

@damianszczepanik
Copy link
Member

Can you clearly show images with version before the change (current implementation) and new one (proposal)?

@AceOfSnakes
Copy link
Author

AceOfSnakes commented Feb 11, 2024

Hi
first image is a a real result of submit in teams with Section.activityImage
teamz latest version

@AceOfSnakes
Copy link
Author

as you see on my first screenshot - border is gray
before changes on microsoft side all works - now all broken
image

@AceOfSnakes
Copy link
Author

AceOfSnakes commented Feb 12, 2024

As designed

With Jenkins plugin With generic webhook connection
teams webhook

Now

With Jenkins plugin With generic webhook connection
image image

Proposed. Real screenshots with Jenkins 2.426.3 LTS in both cases

With Jenkins plugin With generic webhook connection
image image

@damianszczepanik
Copy link
Member

as you see on my first screenshot - border is gray before changes on microsoft side all works - now all broken image

This one is supported by additional the plugin that was not supported from quite long - that could be a problem as well

@damianszczepanik
Copy link
Member

damianszczepanik commented Feb 12, 2024

Ok, so what is the goal for this change? Are you going to avoid having button 'show more' ? What the Jenkins logo come from ?

@AceOfSnakes
Copy link
Author

AceOfSnakes commented Feb 13, 2024

The goal of this change is to display build status with jenkins logo. Images stored in plugin resources and transfer in message body.
Build started : blue logo
Success : green logo
Aborted : gray logo
Unstable : yellow logo
Failed: red logo
All other fuhctiionality unchaged.

"activityImage": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAABg2lDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9Ti........"

image

looks like developers of MS teams after adding theme change in teams no more use "themeColor": "#CC0003" in any cases

@damianszczepanik
Copy link
Member

I don't see value of having Jenkins logo with colors. I don't want to maintain images here. There is clear information about build status and having additional fancy logo does not bring any value

@martens-d
Copy link

The elephant in the room is, that M$ will stop the support for the old MessageCards. I tested the newer AdaptiveCard.
The Jenkins plugin does not support that. But if you use Incoming Webhook connector I was able to post AdaptiveCards.

They support "colors" sort of and do not fold up.
I use a shared lib for messages to teams and I do it like this:

def payload = """{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "contentUrl": null,
      "content": {
        "type": "AdaptiveCard",
        "\$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.6",
        "msteams": { "width": "Full" },
        "body": [
          {
            "type": "Container",
            "style": "##STATUS##",
            "bleed": true,
            "items": [
              {
                "type": "RichTextBlock",
                "inlines": [
                  {
                    "type": "TextRun",
                    "text": "Nachricht von ${env.JOB_BASE_NAME}",
                    "size": "Large",
                    "weight": "bolder"
                  }
                ]
              }
            ]
          },
          {
            "type": "Container",
            "items": [
              {
                "type": "RichTextBlock",
                "inlines": [
                  {
                    "type": "TextRun",
                    "text": "##MESSAGE##"
                  }
                ]
              }
            ]
          },
          {
            "type": "FactSet",
            "facts": [
              "##FACT##"
            ]
          }
        ]
      }
    }
  ]
}"""

    def payload_fact = """{
              "title": "##TITEL##",
              "value": "##VALUE##"
            }"""

...

switch ( Status ) {
      case "SUCCESS":
        status_color = "good";
        break; 
      case "UNSTABLE": 
        status_color = "warning";
        break; 
      case "FAILURE": 
        status_color = "attention";
        break; 
      case "NOT_BUILT": 
        status_color = "warning";
        break; 
      case "ABORTED": 
        status_color = "accent";
        break; 
      default: 
        status_color = "default";
        break;
    } 

def payload_factlist = payload_fact.replace("##TITEL##", "Status").replace("##VALUE##", "${Status}");

if (Facts != null)
    {
      Facts.eachWithIndex{ entry, index ->
        payload_factlist = payload_factlist + ',' + payload_fact.replace("##TITEL##", entry.key).replace("##VALUE##", entry.value)
      }
    }

    payload = payload.replace("##STATUS##", status_color).replace("##FACT##", payload_factlist);

httpRequest(authentication: CREDENTIALS,
                      quiet: !debug,
                      contentType: 'APPLICATION_JSON_UTF8',
                      httpMode: 'POST',
                      requestBody: payload,
                      url: Webhook);

using it like so:

office.sendStatusMessage(
          Status: currentBuild.result, 
          Message: "${JOB_NAME} - ${BUILD_DISPLAY_NAME}\nerfogreiche Freigabe mit Fehlern",
          Facts: [
            "Dauer": currentBuild.durationString.replace(' und läuft', ''),
            "Gestartet durch": currentBuild.getBuildCauses('hudson.model.Cause$UserIdCause').userName[0],
            "Fehler": "Die Programme konnten nicht erfolgreich compiliert werden."],
          Webhook: "...")

this is what it looks like: (it's in german mind, but you get the idea)
grafik

Since I am only working with pipelines, this is no issue, but the plugin needs to be change in order for this to work with freestyle projects.

I even have another message type with an image (in the body of the ActiveCard):

         {
            "type": "Table",
            "columns": [
                {
                    "width": 1
                }
            ],
            "rows": [
                {
                    "type": "TableRow",
                    "cells": [
                        {
                            "type": "TableCell",
                            "bleed": true,
                            "items": [
                                {
                                    "type": "TextBlock"
                                }
                            ],
                            "style": "##COLOR##"
                        }
                    ]
                }
            ],
            "showGridLines": false,
            "firstRowAsHeaders": false
        },
        {
            "type": "Table",
            "bleed": true,
            "columns": [{"width": "60px"}, {"width": 1}],
            "rows": [
                {
                    "type": "TableRow",
                    "cells": [{
                            "type": "TableCell",
                            "items": [{
                                    "type": "Image",
                                    "url": "##IMAGE##",
                                    "style": "Person"
                                }],
                            "horizontalAlignment": "Center"
                        },
...

You can put an image as base64 there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants