jenkinsci / google-chat-notification-plugin

Google Chat Notification Jenkins Plugin to send build status
https://plugins.jenkins.io/google-chat-notification/
MIT License
39 stars 20 forks source link

java.util.UnknownFormatConversionException: Conversion = 'M' #64

Closed Redirts closed 10 months ago

Redirts commented 10 months ago

Jenkins and plugins versions report

Environment ``` Jenkins: 2.414.1 OS: Linux - 3.10.0-1127.el7.x86_64 Java: 11.0.15 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- ... google-chat-notification:1.8.0 ... ```

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

CentOS

Reproduction steps

The notification was working fine in v1.7.1 but now fails. We did not change anything except update.

googlechatnotification url: 'xxx', message: '$JOB_NAME Status $BUILD_STATUS with Commit Message: '+commit_message+' By: '+author_name+'. See $BUILD_URL', notifyAborted: 'true', notifyFailure: 'true', notifyNotBuilt: 'true', notifySuccess: 'false', notifyUnstable: 'true', notifyBackToNormal: 'true', suppressInfoLoggers: 'false', sameThreadNotification: 'false'

Expected Results

No errors

Actual Results

[Google Chat Notification] will send OnBackToNormalNotification because build matches and user preferences allow it [Google Chat Notification] Send Google Chat Notification condition is: true [Google Chat Notification] Will send message to the thread: null. If it doesnt exist yet, it will be created. [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // node Error when executing always post condition: Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 028c14f8-6ad2-4a94-8eb3-b7a017c9e3fa java.util.UnknownFormatConversionException: Conversion = 'M' at java.base/java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2839) at java.base/java.util.Formatter$FormatSpecifier.(Formatter.java:2865) at java.base/java.util.Formatter.parse(Formatter.java:2713) at java.base/java.util.Formatter.format(Formatter.java:2655) at java.base/java.util.Formatter.format(Formatter.java:2609) at java.base/java.lang.String.format(String.java:2897) at jenkins.plugins.googlechat.logging.GoogleChatNotificationsLogger.info(GoogleChatNotificationsLogger.java:50) at io.cnaik.service.LogUtil.printLog(LogUtil.java:27) at io.cnaik.service.CommonUtil.send(CommonUtil.java:34) at io.cnaik.GoogleChatNotification.performAction(GoogleChatNotification.java:432) at io.cnaik.GoogleChatNotification.perform(GoogleChatNotification.java:270) at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:101) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:71) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)

Anything else?

No response

Are you interested in contributing a fix?

No response

letajmal commented 10 months ago

I have a similar issue, mine was with messageFormat: 'simple', parameter. Rollback to 1.7.1 fixed the issue https://github.com/jenkinsci/google-chat-notification-plugin/issues/65#issue-2076626794

Ryudo302 commented 10 months ago

Probably the cause is that your notification message contains a '%' in its body, preceded by a 'M...'. I will fix it to escape any '%' occurrence.