Webhook to Slack Incoming Webhooks fails with "invalid_payload" reponse

1,016 views
Skip to first unread message

ernesto...@edimetel.com

unread,
Nov 14, 2017, 10:09:32 AM11/14/17
to Nexus Users
Hello to everyone,
has anyone experienced success with Capabilities Webhook:Repository in order to have Slack alerts when a new mvn deploy is run?
I have setup the Webhook Nuxus side pointing to a Slack WebHook URL bound to a Slack channel: When I run mvn deploy on the repositoy setup in Nexus Capability I get the following error in nexus.log:

ERROR [event-7-thread-9] xxx org.sonatype.nexus.internal.webhooks.WebhookServiceImpl - Failed to send webhook request: WebhookRequest{id='046ad898-b3f4-4c88-85d2-06c4b07a4cf9', webhook=rm:repository:component, payload=org.sonatype.nexus.repository.webhooks.RepositoryComponentWebhook$RepositoryComponentWebhookPayload@c7094c, url=https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}

org.apache.http.client.HttpResponseException: missing_text_or_fallback_or_attachments

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)

at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:255)

at org.sonatype.nexus.internal.webhooks.WebhookServiceImpl$_send_closure1$_closure2.doCall(WebhookServiceImpl.groovy:151)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)

at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)

at groovy.lang.Closure.call(Closure.java:414)

at groovy.lang.Closure.call(Closure.java:430)

at org.codehaus.groovy.runtime.IOGroovyMethods.withCloseable(IOGroovyMethods.java:1622)

at org.codehaus.groovy.runtime.NioGroovyMethods.withCloseable(NioGroovyMethods.java:1754)

at sun.reflect.GeneratedMethodAccessor160.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)

at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

at org.sonatype.nexus.internal.webhooks.WebhookServiceImpl$_send_closure1.doCall(WebhookServiceImpl.groovy:140)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)

at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)

at groovy.lang.Closure.call(Closure.java:414)

at groovy.lang.Closure.call(Closure.java:430)

at org.codehaus.groovy.runtime.IOGroovyMethods.withCloseable(IOGroovyMethods.java:1622)

at org.codehaus.groovy.runtime.NioGroovyMethods.withCloseable(NioGroovyMethods.java:1754)

at sun.reflect.GeneratedMethodAccessor160.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)

at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

at org.sonatype.nexus.internal.webhooks.WebhookServiceImpl.send(WebhookServiceImpl.groovy:126)

at org.sonatype.nexus.webhooks.WebhookService$send.callCurrent(Unknown Source)

at org.sonatype.nexus.internal.webhooks.WebhookServiceImpl.on(WebhookServiceImpl.groovy:105)

at sun.reflect.GeneratedMethodAccessor185.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)

at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)

at org.sonatype.nexus.thread.internal.MDCAwareRunnable.run(MDCAwareRunnable.java:40)

at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120)

at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)


My feeling is there is some error in the way Nexus generate the payload sent to Slack.

Thanks in advance for you help,
Ernesto Ferrari




Kelly Robinson

unread,
Nov 14, 2017, 12:55:07 PM11/14/17
to ernesto...@edimetel.com, Nexus Users
Hi Ernesto,

I think there's some confusion here, our webhooks feature is not intended to communicate with Slack directly, and does not provide a compatible json payload. The webhooks feature can be configured to send information about Component and Asset events in NXRM3 to a separate server, with data payloads as described in the Java classes extending WebhookPayload here: https://github.com/sonatype/nexus-public/tree/master/components/nexus-repository/src/main/java/org/sonatype/nexus/repository/webhooks and described in documentation here: https://help.sonatype.com/display/NXRM3/Example+Headers+And+Payloads. You could write a simple server to listen for these events, transform them and pass them on to Slack in the expected format.
Hope that helps, and I'm happy to answer any other questions you might have.


--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/9b83874e-5260-4b7e-88e2-38070b07461a%40glists.sonatype.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.

Reply all
Reply to author
Forward
0 new messages