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

googlechatnotification CARD message format throws NotSerializableException #86

Open
hughdsrf opened this issue May 22, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@hughdsrf
Copy link

hughdsrf commented May 22, 2024

Jenkins and plugins versions report

Environment
Jenkins: 2.440.3
OS: Linux - 6.1.0-18-amd64
Java: 17.0.10 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
additional-metrics:67.vcb_823d3999a_2
ant:497.v94e7d9fffa_b_9
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
asm-api:9.7-33.v4d23ef79fcc8
authentication-tokens:1.53.v1c90fd9191a_b_
badge:1.11
blueocean:1.27.12
blueocean-bitbucket-pipeline:1.27.12
blueocean-commons:1.27.12
blueocean-config:1.27.12
blueocean-core-js:1.27.12
blueocean-dashboard:1.27.12
blueocean-display-url:2.4.2
blueocean-events:1.27.12
blueocean-git-pipeline:1.27.12
blueocean-github-pipeline:1.27.12
blueocean-i18n:1.27.12
blueocean-jwt:1.27.12
blueocean-personalization:1.27.12
blueocean-pipeline-api-impl:1.27.12
blueocean-pipeline-editor:1.27.12
blueocean-pipeline-scm-api:1.27.12
blueocean-rest:1.27.12
blueocean-rest-impl:1.27.12
blueocean-web:1.27.12
bootstrap5-api:5.3.3-1
bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9
branch-api:2.1169.va_f810c56e895
build-timeout:1.32
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.2.0
cloudbees-bitbucket-branch-source:886.v44cf5e4ecec5
cloudbees-folder:6.901.vb_4c7a_da_75da_3
command-launcher:107.v773860566e2e
commons-lang3-api:3.13.0-62.v7d18e55f51e2
commons-text-api:1.11.0-109.vfe16c66636eb_
credentials:1337.v60b_d7b_c7b_c9f
credentials-binding:677.vdc9d38cb_254d
dark-theme:439.vdef09f81f85e
display-url-api:2.204.vf6fddd8a_8b_e9
durable-task:555.v6802fe0f0b_82
echarts-api:5.5.0-1
email-ext:1814.v404722f34263
envinject:2.908.v66a_774b_31d93
envinject-api:1.199.v3ce31253ed13
favorite:2.208.v91d65b_7792a_c
font-awesome-api:6.5.2-1
git:5.2.2
git-client:4.7.0
github:1.39.0
github-api:1.318-461.v7a_c09c9fa_d63
github-branch-source:1789.v5b_0c0cea_18c3
google-chat-notification:141.va_4b_b_6a_25483c
gradle:2.12
groovy:457.v99900cb_85593
groovy-postbuild:228.vcdb_cf7265066
gson-api:2.10.1-15.v0d99f670e0a_7
handy-uri-templates-2-api:2.1.8-30.v7e777411b_148
htmlpublisher:1.33
instance-identity:185.v303dc7c645f9
ionicons-api:74.v93d5eb_813d5f
jackson2-api:2.17.0-379.v02de8ec9f64c
jakarta-activation-api:2.1.3-1
jakarta-mail-api:2.1.3-1
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
jaxb:2.3.9-1
jdk-tool:73.vddf737284550
jenkins-design-language:1.27.12
jjwt-api:0.11.5-112.ve82dfb_224b_a_d
joda-time-api:2.12.7-29.v5a_b_e3a_82269a_
jquery3-api:3.7.1-2
json-api:20240303-41.v94e11e6de726
json-path-api:2.9.0-58.v62e3e85b_a_655
junit:1265.v65b_14fa_f12f0
ldap:725.v3cb_b_711b_1a_ef
mailer:472.vf7c289a_4b_420
matrix-auth:3.2.2
matrix-project:822.824.v14451b_c0fd42
mina-sshd-api-common:2.12.1-101.v85b_e08b_780dd
mina-sshd-api-core:2.12.1-101.v85b_e08b_780dd
okhttp-api:4.11.0-172.vda_da_1feeb_c6e
pam-auth:1.10
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-github-lib:42.v0739460cda_c4
pipeline-graph-analysis:216.vfd8b_ece330ca_
pipeline-groovy-lib:710.v4b_94b_077a_808
pipeline-input-step:495.ve9c153f6067b_
pipeline-milestone-step:119.vdfdc43fc3b_9a_
pipeline-model-api:2.2198.v41dd8ef6dd56
pipeline-model-definition:2.2198.v41dd8ef6dd56
pipeline-model-extensions:2.2198.v41dd8ef6dd56
pipeline-rest-api:2.34
pipeline-stage-step:312.v8cd10304c27a_
pipeline-stage-tags-metadata:2.2198.v41dd8ef6dd56
pipeline-stage-view:2.34
plain-credentials:182.v468b_97b_9dcb_8
plugin-util-api:4.1.0
pubsub-light:1.18
resource-disposer:0.23
scm-api:690.vfc8b_54395023
script-security:1336.vf33a_a_9863911
snakeyaml-api:2.2-111.vc6598e30cc65
sse-gateway:1.26
ssh-credentials:337.v395d2403ccd4
ssh-slaves:2.948.vb_8050d697fec
sshd:3.322.v159e91f6a_550
structs:337.v1b_04ea_4df7c8
theme-manager:215.vc1ff18d67920
timestamper:1.27
token-macro:400.v35420b_922dcb_
trilead-api:2.142.v748523a_76693
variant:60.v7290fc0eb_b_cd
workflow-aggregator:596.v8c21c963d92d
workflow-api:1311.v4250456a_e552
workflow-basic-steps:1058.vcb_fc1e3a_21a_9
workflow-cps:3894.3896.vca_2c931e7935
workflow-durable-task-step:1353.v1891a_b_01da_18
workflow-job:1400.v7fd111b_ec82f
workflow-multibranch:773.vc4fe1378f1d5
workflow-scm-step:427.v4ca_6512e7df1
workflow-step-api:657.v03b_e8115821b_
workflow-support:907.v6713a_ed8a_573
ws-cleanup:0.45

What Operating System are you using (both controller, and any agents involved in the problem)?

Only using controller and the OS is Debian 12

Reproduction steps

I am running the following in a post build step

stage('PostBuild') {
            steps {
                script {
println "Calculating BUILD_DURATION"

Jenkins.instance?.items.each { job ->
  if (job.name == "Spotter_test") {

try {

  def build = job.getLastBuild()

    if ( build != null ) {
    //   def duration = build.getDuration()
    
      def currentTime = System.currentTimeMillis()
      def startBuild =  build.getStartTimeInMillis()
      def duration = currentTime - startBuild
    
      println "got Duration of " + duration

      def buildDuration = Util.getTimeSpanString(duration)
      
      println "Duration string: " + buildDuration

      def strMessage = String.format('''{
  "header": {
    "title": "Jenkins",
    "subtitle": "${JOB_NAME} ${BUILD_ID}",
  },
  "sections": [
    {
      "header": "${BUILD_STATUS}",
      "collapsible": false,
      "uncollapsibleWidgetsCount": 1,
      "widgets": [
        {
          "divider": {}
        },
        {
          "textParagraph": {
            "text": "Duration: %s"
          }
        },
        {
          "divider": {}
        },
        {
          "buttonList": {
            "buttons": [
              {
                "text": "OPEN BUILD",
                "onClick": {
                  "openLink": {
                    "url": "${BUILD_URL}"
                  }
                },
                "disabled": false
              },
            ]
          }
        }
      ]
    }
  ]
}''', buildDuration)
    

googlechatnotification message: strMessage, messageFormat: 'SIMPLE', threadKey: '${JOB_NAME} #${BUILD_ID}', url: '<chat space webhook URL>
                
    }

} catch (Exception e) {
  println "Failed with exception " + e
}
}

  }
}

                }
        }
'

When this is run with <messageFormat: "SIMPLE"> it sends the text to the specified chat space.
When the messageFormat is changed to "CARD" it throws this exception:

{"header":{"subtitle":"Spotter_test 172","title":"New Jenkins"},"sections":[{"header":"<font color=\"#5DBCD2\">SUCCESS<\/font>","uncollapsibleWidgetsCount":1,"widgets":[{"divider":{}},{"textParagraph":{"text":"Duration: %s"}},{"divider":{}},{"buttonList":{"buttons":[{"onClick":{"openLink":{"url":"http://192.168.15.140:8080/job/Spotter_test/172/"}},"disabled":false,"text":"OPEN BUILD"}]}}],"collapsible":false}]}
[Pipeline] echo
Failed with exception java.io.NotSerializableException: hudson.model.FreeStyleProject

Expected Results

To be able to display a card with the build results in Google Chat space.

Actual Results

Nothing shows up in the Google Chat space when messageFormat is set to "CARD"

Anything else?

No response

Are you interested in contributing a fix?

No response

@hughdsrf hughdsrf added the bug Something isn't working label May 22, 2024
@Ryudo302 Ryudo302 self-assigned this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants