tcplugins / tcwebhooks Goto Github PK
View Code? Open in Web Editor NEWWebHooks plugin for Teamcity. Supports many build states and payload formats.
Home Page: https://netwolfuk.wordpress.com/category/teamcity/tcplugins/tcwebhooks/
WebHooks plugin for Teamcity. Supports many build states and payload formats.
Home Page: https://netwolfuk.wordpress.com/category/teamcity/tcplugins/tcwebhooks/
Is there any particular reason why I can't customize the events to sent when I select slack JSON payload?
We are running tons of builds a day and I only want to notify the slack channel when the status changes from success to failure and vice versa.
We are using tcWebHooks version 0.9.27.61 on TeamCity 9.0.2 build 32915 on several projects; thank you for creating this plugin!
I moved a build configuration from one project to another and noticed that the WebHook was removed after the move. In the TeamCity server log, we see this event confirming success of the move:
[2015-07-27 21:56:39,926] INFO - tbrains.buildServer.ACTIVITIES - "Old Project :: My Build Configuration {id=..., internal id=...}" was moved from "New Project :: My Build Configuration" by "'user' (...) {id=...}"
We later re-added the WebHook to the build configuration and things work as expected.
Do you know of any way to preserve the build configuration's WebHooks when moving to different projects?
At the moment, if you want the branch in the payload, you have to hack the template yourself.
It would be nicer to do that automatically if the VCS supports branching on a single build.
[2016-08-18 13:14:32,218] WARN - ildServer.util.EventDispatcher - Error in event handler: java.lang.NullPointerException
java.lang.NullPointerException
at webhook.teamcity.payload.format.WebHookPayloadJsonTemplate.getStatusAsString(WebHookPayloadJsonTemplate.java:43)
at webhook.teamcity.payload.format.WebHookPayloadGeneric.buildFinished(WebHookPayloadGeneric.java:64)
at webhook.teamcity.WebHookContentBuilder.buildWebHookContent(WebHookContentBuilder.java:78)
at webhook.teamcity.WebHookListener.processBuildEvent(WebHookListener.java:78)
at webhook.teamcity.WebHookListener.buildFinished(WebHookListener.java:138)
at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at jetbrains.buildServer.util.EventDispatcher.dispatch(EventDispatcher.java:121)
at jetbrains.buildServer.serverSide.ServerSideEventDispatcher.superDispatch(ServerSideEventDispatcher.java:6)
at jetbrains.buildServer.serverSide.ServerSideEventDispatcher$1.run(ServerSideEventDispatcher.java:1)
at jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAs(SecurityContextImpl.java:3)
at jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAsSystem(SecurityContextImpl.java:11)
at jetbrains.buildServer.serverSide.ServerSideEventDispatcher.dispatch(ServerSideEventDispatcher.java:12)
at jetbrains.buildServer.util.EventDispatcher$2.invoke(EventDispatcher.java:68)
at com.sun.proxy.$Proxy19.buildFinished(Unknown Source)
at jetbrains.buildServer.serverSide.impl.RunningBuildsManagerImpl.finishBuild(RunningBuildsManagerImpl.java:24)
at jetbrains.buildServer.serverSide.impl.RunningBuildsManagerImpl.access$600(RunningBuildsManagerImpl.java:198)
at jetbrains.buildServer.serverSide.impl.RunningBuildsManagerImpl$5.run(RunningBuildsManagerImpl.java:2)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Browse to endpoint-viewer.html
Expected text
To have items displayed here, configure a webhook to post to http://localhost:8111/webhooks/endpoint.html
Actual text:
To have items displayed here, configure a webhook to post to http://localhost:8111webhooks/endpoint.html
tcWebHooksPlugin-1.1-alpha7.122.138
TeamCity 10.0.1 (build 42078)
CentOS Linux release 7.1.1503
XML parsing in tcWebHooks is ugly.
trying to use any teamcity variables like %teamcity.build.id%, etc in a 'build started' trigger in tailored json are not substituted, the whole body ends up being sent verbatim. all other triggers do get substituted correctly. Is this something that is possible to fix?
Since tailored JSON only uses a single TC parameter (webhook.body
), if for instance you want a custom color
parameter that is different between the success and failure webhooks, there's no way that I can see to define $(color)
for a specific webhook.
Happy to work on this, just want to have the discussion here first.
Yeah, in the UI.
From teamcity-server.log:
ERROR - jetbrains.buildServer.SERVER - Error javax.servlet.jsp.JspException: java.lang.NumberFormatException: For input string: "webHookList" while processing request: GET '/webhooks/index.html?buildTypeId=BuildSandbox_TestBuild', from client 10.000.00.00:00000, authenticated as 'aUser' (A User) {id=3}
The webhooks notification worked as expected.
How serious of an issue is this for the server?
TeamCity 10.0.1 (build 42078)
tcWebHooksPlugin-1.1.109.134
I run a TeamCity server with multiple projects on it. It's really a pain to have to root around the filesystem of the server to update things like the custom templates and extra parameters for each project.
It would be very helpful to expose these options in the Web UI.
I have a custom template like this:
{
"notifyType": "${notifyType}"
"config": "${config}",
"sha": "${build.vcs.number}"
}
where config
is a build parameter. The resulting payload is unfortunately this:
{
"notifyType": "buildStarted",
"config": "UNRESOLVED",
"sha": "UNRESOLVED"
}
Only a predefined notifyType
got unresolved. I've checked that wehbook.*
works too. But none of build parameters or env.*
get resolved. Is it still possible with templates? Is there any workaround?
I'm on TeamCity 9.1.4, the same happens with nvpairs format.
Server Info:
CentOS Linux release 7.1.1503
TeamCity 10.0.1 (build 42078)
tcWebHooksPlugin-1.1.109.134
plugin-settings.xml:
<?xml version="1.0" encoding="UTF-8"?> <settings> <webhooks enabled="true"> <webhook url="http://some.web.page:8080/a/folder" enabled="false" format="json" template="none"> <states> <state type="buildSuccessful" enabled="true" /> <state type="buildBroken" enabled="false" /> <state type="buildFailed" enabled="true" /> <state type="buildStarted" enabled="true" /> <state type="buildFixed" enabled="false" /> <state type="buildFinished" enabled="true" /> <state type="responsibilityChanged" enabled="true" /> <state type="changesLoaded" enabled="true" /> <state type="buildInterrupted" enabled="true" /> <state type="beforeBuildFinish" enabled="true" /> </states> <build-types enabled-for-all="true" enabled-for-subprojects="true" /> </webhook> </webhooks> </settings>
teamcity-server.log:
INFO - jetbrains.buildServer.SERVER - java.lang.NullPointerException webhook.teamcity.payload.template.render.WebHookStringRenderer$WebHookHtmlRendererException: java.lang.NullPointerException at webhook.teamcity.payload.template.render.JsonToHtmlPrettyPrintingRenderer.render(JsonToHtmlPrettyPrintingRenderer.java:29) at webhook.teamcity.extension.WebHookTemplateRenderingController.doHandle(WebHookTemplateRenderingController.java:104) at jetbrains.buildServer.controllers.BaseController.handleRequestInternal(BaseController.java:75) at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:147) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at jetbrains.buildServer.maintenance.TeamCityDispatcherServlet.service(TeamCityDispatcherServlet.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at jetbrains.buildServer.web.DisableSessionIdFromUrlFilter.doFilter(DisableSessionIdFromUrlFilter.java:8) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107) at jetbrains.buildServer.diagnostic.web.DiagnosticFilter.doFilter(DiagnosticFilter.java:44) at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:112) at jetbrains.buildServer.web.DependencyParametersCalculationContextFilter.doFilter(DependencyParametersCalculationContextFilter.java:2) at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:112) at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73) at jetbrains.buildServer.web.DelegatingFilter.doFilter(DelegatingFilter.java:7) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at jetbrains.buildServer.web.ResponseFragmentFilter.doFilter(ResponseFragmentFilter.java:20) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1757) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1716) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at java.io.StringReader.<init>(StringReader.java:50) at com.google.gson.JsonParser.parse(JsonParser.java:45) at webhook.teamcity.payload.template.render.JsonToHtmlPrettyPrintingRenderer.render(JsonToHtmlPrettyPrintingRenderer.java:20) ... 46 more
TeamCity version: 9.1.6
Server OS: Windows Server 2008 R2
Plugin version: 0.9.35.72 (Latest stable release on GitHub), also tested with 0.9.74.76 (latest master
build on teamcity.jetbrains.com) and 1.1-alpha4.54.105 (latest alpha release on GitHub)
Symptoms: When a build with webhooks defined completes, the following is written to teamcity-server.log
:
[2016-03-16 11:56:40,065] DEBUG - jetbrains.buildServer.SERVER - About to process WebHooks for project408 at buildState buildStarted
[2016-03-16 11:56:40,066] WARN - ildServer.util.EventDispatcher - Error in event handler: java.lang.IllegalStateException: Unable to create settings for webhooks; corresponding factory was not registered
[2016-03-16 11:56:40,066] DEBUG - ildServer.util.EventDispatcher - Error in event handler
java.lang.IllegalStateException: Unable to create settings for webhooks; corresponding factory was not registered
at jetbrains.buildServer.serverSide.settings.ProjectSettingsManagerImpl.getFactory(ProjectSettingsManagerImpl.java:47)
at jetbrains.buildServer.serverSide.settings.ProjectSettingsManagerImpl.getSettings(ProjectSettingsManagerImpl.java:1)
at webhook.teamcity.WebHookListener.getListOfEnabledWebHooks(WebHookListener.java:135)
at webhook.teamcity.WebHookListener.processBuildEvent(WebHookListener.java:98)
at webhook.teamcity.WebHookListener.buildStarted(WebHookListener.java:170)
at sun.reflect.GeneratedMethodAccessor245.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at jetbrains.buildServer.util.EventDispatcher.dispatch(EventDispatcher.java:120)
at jetbrains.buildServer.serverSide.ServerSideEventDispatcher.superDispatch(ServerSideEventDispatcher.java:13)
at jetbrains.buildServer.serverSide.ServerSideEventDispatcher$1.run(ServerSideEventDispatcher.java:1)
at jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAs(SecurityContextImpl.java:8)
at jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAsSystem(SecurityContextImpl.java:10)
at jetbrains.buildServer.serverSide.ServerSideEventDispatcher.dispatch(ServerSideEventDispatcher.java:7)
at jetbrains.buildServer.util.EventDispatcher$2.invoke(EventDispatcher.java:67)
at com.sun.proxy.$Proxy19.buildStarted(Unknown Source)
at jetbrains.buildServer.serverSide.impl.BuildStarter$1.run(BuildStarter.java:11)
at jetbrains.buildServer.serverSide.impl.BuildStarter$2$1.run(BuildStarter.java:1)
at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:89)
at jetbrains.buildServer.serverSide.impl.BuildStarter$2.run(BuildStarter.java:1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
The same exception is also thrown when navigating to the 'WebHooks' tab in the TeamCity UI:
[2016-03-16 12:52:37,497] WARN - jetbrains.buildServer.SERVER - Unhandled exception occurred while calling method fillModel of WebHookProjectTabExtension[myIncludeUrl='/project/webHooks.jsp', myPluginName='webHooks', myPlaceId=/project.html#PROJECT@TAB] extension.
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor278.invoke(Unknown Source)
[snip]
Caused by: java.lang.IllegalStateException: Unable to create settings for webhooks; corresponding factory was not registered
at jetbrains.buildServer.serverSide.settings.ProjectSettingsManagerImpl.getFactory(ProjectSettingsManagerImpl.java:47)
at jetbrains.buildServer.serverSide.settings.ProjectSettingsManagerImpl.getSettings(ProjectSettingsManagerImpl.java:1)
at webhook.teamcity.extension.WebHookProjectTabExtension.fillModel(WebHookProjectTabExtension.java:63)
at jetbrains.buildServer.web.openapi.project.ProjectTab.fillModel(ProjectTab.java:60)
... 50 more
Unfortunately, I have no idea when this started happening -- I set up the webhooks plugin months ago when we were still running TC8 and I didn't notice that it had stopped working until today.
We just updated to version 1.1-alpha4.54.105 in order to use the built-in support for Flowdock. After installing the plugin and restarting the server, we don't have Flowdock as an option in the payload formats list. Checking the TC server log, we're seeing the following errors when the plugin starts up:
[2015-12-07 12:58:43,321] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildStarted-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,321] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildBroken-buildFailed-buildInterrupted-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,322] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildSuccessful-buildFixed-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,322] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildBroken-buildFailed-buildInterrupted-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,322] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildSuccessful-buildFixed-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,322] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildBroken-buildFailed-buildInterrupted-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,323] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-responsibilityChanged-normal.json. The file was not found in the classpath.
[2015-12-07 12:58:43,323] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildStarted-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,323] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildBroken-buildFailed-buildInterrupted-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,324] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildSuccessful-buildFixed-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,324] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildBroken-buildFailed-buildInterrupted-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,324] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildSuccessful-buildFixed-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,324] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-buildBroken-buildFailed-buildInterrupted-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,325] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: An Error occurred trying to load the template file: webhook/teamcity/payload/template/flowdock\flowdock-responsibilityChanged-branch.json. The file was not found in the classpath.
[2015-12-07 12:58:43,325] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: Failed to register template flowdock. No regular template configurations were found.
[2015-12-07 12:58:43,378] ERROR - jetbrains.buildServer.SERVER - FlowdockWebHookTemplate :: Failed to register template flowdock. No branch template configurations were found.
None of the other templates had an issue - they all loaded successfully.
If there's any additional info we can provide to help troubleshoot this, let me know, and thanks for the great plugin!
javax.servlet.jsp.JspException: java.lang.NumberFormatException: For input string: "webHookList"
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp$Helper.invoke(index_jsp.java:2061)
at org.apache.jsp.tag.web.page_tag.doTag(page_tag.java:724)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspx_meth_bs_005fpage_005f0(index_jsp.java:221)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspService(index_jsp.java:161)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at jetbrains.spring.web.TeamCityJSPServletImpl.access$001(TeamCityJSPServletImpl.java:21)
at jetbrains.spring.web.TeamCityJSPServletImpl$2.apply(TeamCityJSPServletImpl.java:40)
at jetbrains.buildServer.util.Util.doUnderContextClassLoader(Util.java:78)
at jetbrains.spring.web.TeamCityJSPServletImpl.service(TeamCityJSPServletImpl.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at jetbrains.spring.web.JspController.doHandle(JspController.java:56)
at jetbrains.buildServer.controllers.BaseController.handleRequestInternal(BaseController.java:75)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:154)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at jetbrains.buildServer.maintenance.TeamCityDispatcherServlet.service(TeamCityDispatcherServlet.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:209)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:267)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1221)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at jetbrains.buildServer.maintenance.TeamCityDispatcherServlet.service(TeamCityDispatcherServlet.java:87)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at jetbrains.buildServer.web.DisableSessionIdFromUrlFilter.doFilter(DisableSessionIdFromUrlFilter.java:21)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
at jetbrains.buildServer.diagnostic.web.DiagnosticFilter.doFilter(DiagnosticFilter.java:77)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:112)
at jetbrains.buildServer.web.DependencyParametersCalculationContextFilter.doFilter(DependencyParametersCalculationContextFilter.java:38)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:112)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
at jetbrains.buildServer.web.DelegatingFilter.doFilter(DelegatingFilter.java:37)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at jetbrains.buildServer.web.ResponseFragmentFilter.doFilter(ResponseFragmentFilter.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1757)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1716)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NumberFormatException: For input string: "webHookList"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at javax.el.ListELResolver.coerce(ListELResolver.java:163)
at javax.el.ListELResolver.getValue(ListELResolver.java:51)
at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
at org.apache.el.parser.AstValue.getValue(AstValue.java:184)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:950)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:908)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspx_meth_c_005fwhen_005f2(index_jsp.java:683)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspx_meth_c_005fchoose_005f2(index_jsp.java:617)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspx_meth_c_005fotherwise_005f1(index_jsp.java:587)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp._jspx_meth_c_005fchoose_005f1(index_jsp.java:526)
at org.apache.jsp.plugins.tcWebHooks.WebHook.index_jsp.access$7(index_jsp.java:509)
The branchName for master comes out as before changes are compiled (eg, for buildStarted event).
Allow a way to convert < to _ so that it displays correctly on webpages.
Our build configurations have special deployment steps associated with e.g. staging and production branches, aside from the general tests runners that are executed on every branch. As a form of auditing production deployments, I want to trigger webhooks specifically for the builds on the production branch. Currently I can only filter based on build configuration, not on the branch. Is it doable for you to implement such a filter?
There are two exceptions which are explicitly versioned for releases, which uses tags (with the build configuration set to treat tags as branches). There is a fixed pattern for the tag/branch names, and we'd like to monitor those specific builds as well.
With the ability to e.g. specify a regex pattern we would be able to tackle all of this.
Edits to webhooks in the _Root project are not persisted.
Update: As of 2019.2, the problematic jar is no longer distributed with TeamCity. Recent versions of tcWebHooks no longer check for this on startup if the TeamCity version is new.
Until this bug and this bug are fixed, the jaxb libraries in the rest-api.zip (bundled with TeamCity) conflict with the ones pulled in by jersey-json (provided by teamcity) which the tcWebHooks REST API code depends on.
This prevents the tcWebHooks REST API from persisting the webhook-templates.xml config to disk because it uses JaxB to serialise to XML.
Therefore, the jaxb*
jars need to be removed from the rest-api.zip
. This can be achieved with the following command.
cd TeamCity && \
zip -d webapps/ROOT/WEB-INF/plugins/rest-api.zip \
server/jaxb-api-2.2.5.jar server/jaxb-impl-2.2.5.jar && \
rm webapps/ROOT/WEB-INF/plugins/.unpacked/rest-api/server/jaxb*.jar && \
bin/teamcity-server.sh stop && sleep 5 && bin/teamcity-server.sh start
As per comments in issue #19
We are using the webhook plugin on our corporate TeamCity.
The webhook authentication password is kept as plain text at the webhook plugin xml.
Would it be possible to store the password encrypted?
Would it be possible to mask the password at the "Extra Config" UI tab?
Thanks
Ofer
The old trunk (from sourceforge) has been left too long. As part of the migration to GitHub, we should start using master as master again.
What I would like to achieve with it is to send the build results (e.g. why the build failed, as it can be seen under /viewLog) to HipChat directly, because would like to avoid the devs having to have credentials for more systems, TC in this case. As far as I can tell, it’s not possible at the moment.
I’m not sure if it’s feasible, but the build log/overview could be a useful addition to the currently available set of object variables as listed in one of your previous blogposts (http://netwolfuk.wordpress.com/2013/08/31/custom-templates-and-branches-in-tcwebhooks).
When admin page created put errors in that page for increased visibility.
The file .BuildServer/config/webhooks-templates.xml is watched and reloaded whenever a change happens.
However, when TeamCity first starts up, the file is read but none of the templates appear to load into TeamCity until the file is edited.
tcWebHooks should read the file on startup and load the templates correctly.
With the latest version (1.1-alpha8.140.143) I created a WebHook with Payload Formal Slack.com and 'Trigger when build Fails' as the only 'On Completion'.
The issue is that I also receive notification when build is Successful...
The responsibilityChanged template for Flowdock needs some love.
Currently there is no way to use HTTP Basic Auth on the API server (that I can see) - the only form of authorization is the proxy authentication, which isn't sufficient. In the most basic form just allowing username and password parameters that are put into a HTTP Authorization header would probably be alright. If you want to make it really clever, you could also include the option of using bearer token authentication (for OAuth support), although for me personally that's currently not required.
My use case is integration with the Bitbucket Cloud REST API, which uses HTTP authentication instead of putting tokens in URLs like HipChat and Slack.
ERROR - jetbrains.buildServer.SERVER - Error jetbrains.buildServer.serverSide.PersistFailedException: java.lang.NullPointerException while processing request: POST '/webhooks/ajaxEdit.html?projectId=project10&URL=http%3A%2F%2Flocalhost%3A8111%2Fwebhooks%2Fendpoint.html%3Fsomething&webHooksEnabled=on&payloadFormatHolder=none_json&BuildStarted=on&ChangesLoaded=on&BuildInterrupted=on&BeforeFinished=on&ResponsibilityChanged=on&BuildSuccessful=on&BuildFailed=on&buildTypeAll=on&buildTypeSubProjects=on&buildTypeId=bt19&buildTypeId=bt18¤tTemplateBuildId=1401¤tTemplateBuildEvent=buildSuccessful&webHookId=new&payloadFormat=json&payloadTemplate=none&submitAction=updateWebHook', from client :38862, authenticated as 'netwolfuk' {id=1}
jetbrains.buildServer.serverSide.PersistFailedException: java.lang.NullPointerException
at jetbrains.buildServer.serverSide.impl.projects.ProjectFileSettingsPersister.writeDocument(ProjectFileSettingsPersister.java:34)
at jetbrains.buildServer.serverSide.impl.projects.ProjectFileSettingsPersister.saveSettings(ProjectFileSettingsPersister.java:17)
at jetbrains.buildServer.serverSide.impl.projects.ProjectImpl.doPersistInternally(ProjectImpl.java:110)
at jetbrains.buildServer.serverSide.impl.projects.ProjectImpl.access$300(ProjectImpl.java:724)
at jetbrains.buildServer.serverSide.impl.projects.ProjectImpl$12$1.run(ProjectImpl.java:2)
at jetbrains.buildServer.serverSide.impl.projects.PersistTaskImpl.run(PersistTaskImpl.java:44)
at jetbrains.buildServer.serverSide.impl.projects.BackgroundPersisterImpl$RunTask.lambda$run$0(BackgroundPersisterImpl.java:4)
at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:74)
at jetbrains.buildServer.serverSide.impl.projects.BackgroundPersisterImpl$RunTask.run(BackgroundPersisterImpl.java:1)
at jetbrains.buildServer.serverSide.impl.projects.BackgroundPersisterImpl$FlushOnDisk.run(BackgroundPersisterImpl.java:7)
at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:74)
at jetbrains.buildServer.util.ExceptionUtil$1.run(ExceptionUtil.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at webhook.teamcity.settings.WebHookConfig.getAsElement(WebHookConfig.java:294)
at webhook.teamcity.settings.WebHookProjectSettings.writeTo(WebHookProjectSettings.java:72)
at jetbrains.buildServer.serverSide.settings.ProjectSettingsManagerImpl.writeTo(ProjectSettingsManagerImpl.java:6)
at jetbrains.buildServer.serverSide.impl.projects.ProjectFileSettingsPersister.writeData(ProjectFileSettingsPersister.java:13)
at jetbrains.buildServer.serverSide.impl.projects.ProjectFileSettingsPersister.writeDocument(ProjectFileSettingsPersister.java:16)
... 19 more
This is an awesome idea for an enhancement. Breaking it out into its own issue since I'd like to work on it and so it can be discussed separately.
From #3:
I'm also wondering about having some prefined global templates for common services like HipChat, Stack, FlowDock, etc so that users can pick them from a list when creating a webhook. I'm still mulling over in my mind about what the "payload customisation" (aka custom template) UI would look like. I imagine it will probably be another tab in the webhook edit screen.
I'd like to use webhooks to integrate gitlab and teamcity, using the comments field to link the two (create a merge, run a build, comment on the merge). It doesn't look like the comments are being sent with the latest stable build. I'm looking for a workaround, but it would be nice to get that extra info.
In my setup I have some variable components of not just the payload but also the URL. I have been able to pass these values to the plugin through build parameters and configure substitution in the URL using the ${varname}
syntax. However, this only seems to work for the events triggered by a completed build (success and failure). I would also like to trigger a hook when a build is started, but that hook doesn't seem to perform proper variable substitution in the URL yet:
Error in event handler: java.lang.IllegalArgumentException: Invalid uri 'https://api.bitbucket.org/2.0/repositories/organization/%system.teamcity.projectName%/commit/%system.build.vcs.number%/statuses/build': Invalid URL encoding (enable debug to see stacktrace)
Note that the configuration has the URL listed as follows:
https://api.bitbucket.org/2.0/repositories/organization/${project}/commit/${revision}/statuses/build
Meaning that there is a certain extent of replacement going on (e.g. ${project}
to %system.teamcity.projectName%
) but not complete enough. Perhaps it's just a matter of that two-pass variable substitution that I've seen mentioned? Note that directly entering the percent-style variable names in the XML file always results in errors, even in the success/failure hooks, so I'm guessing it's a primary pass that is missing (that substitutes the percent-style variables with their actual values) instead of a secondary pass (for the dollar-style substitution).
(The API URLs have been anonymized.)
Can't see webhooks for cancelled jobs
There isn't a single example in the docs. It would be nice to have a reference, especially since it's very difficult to prototype with Team City if you're not an administrator or have other constraints at your organization.
Thanks.
This is more a feature suggestion, but it would be also nice to have two more hooks to monitor build queue, to see that your build is in queue. I imagine two new web hook events:
Didn't investigate the API of TC if it is feasable, but that we can investigate / discuss here if someone decide to do it.
Wrap this in try/catch and log an error if it's NULL.
This should not be NULL for this template.
It results in an empty payload, so it's still worth firing the webhook off, rather than failing to send it.
I put this in my config/webhook-templates.xml
and I don't see any new templates in my template selector. I'm on tcWebHooks version: 1.1.109.134
<?xml version="1.0" encoding="UTF-8"?>
<webhook-templates>
<webhook-template enabled="true" name="slack" rank="30">
<template-description>Slack Integration</template-description>
<template-tool-tip value="Slack"/>
<formats>
<format name="jsontemplate" enabled="true" />
</formats>
<templates>
<template>
<template-text><![CDATA[
{
"attachments": [
{
"fallback": "${buildName} <${buildStatusUrl}|build #${buildNumber}> was successful",
"text": "${buildName} <${buildStatusUrl}|build #${buildNumber}> was successful.",
"color": "good"
}
]
}
]]></template-text>
<branch-template-text><![CDATA[
{
"attachments": [
{
"fallback": "${buildName} <${buildStatusUrl}|build #${buildNumber}> branch: ${branchName} was successful",
"text": "${buildName} <${buildStatusUrl}|build #${buildNumber}> branch: ${branchName} was successful.",
"color": "good"
}
]
}
]]></branch-template-text>
<states>
<!-- <state type="buildBroken" enabled="true" /> -->
<!-- <state type="changesLoaded" enabled="true" /> -->
<!-- <state type="buildInterrupted" enabled="true" /> -->
<!-- <state type="buildFixed" enabled="true" /> -->
<!-- <state type="buildFinished" enabled="true" /> -->
<!-- <state type="buildStarted" enabled="true" /> -->
<!-- <state type="responsibilityChanged" enabled="true" /> -->
<state type="buildSuccessful" enabled="true" />
<!-- <state type="buildFailed" enabled="true" /> -->
<!-- <state type="beforeBuildFinish" enabled="true" /> -->
</states>
</template
<template>
<template-text><![CDATA[
{
"attachments": [
{
"fallback": "${buildName} <${buildStatusUrl}|build #${buildNumber}> failed",
"text": "${buildName} <${buildStatusUrl}|build #${buildNumber}> failed",
"color": "danger"
}
]
}
]]></template-text>
<branch-template-text><![CDATA[
{
"attachments": [
{
"fallback": "${buildName} <${buildStatusUrl}|build #${buildNumber}> branch: ${branchName} failed",
"text": "${buildName} <${buildStatusUrl}|build #${buildNumber}> branch: ${branchName} failed",
"color": "danger"
}
]
}
]]></branch-template-text>
<states>
<!-- <state type="buildBroken" enabled="true" /> -->
<!-- <state type="changesLoaded" enabled="true" /> -->
<!-- <state type="buildInterrupted" enabled="true" /> -->
<!-- <state type="buildFixed" enabled="true" /> -->
<!-- <state type="buildFinished" enabled="true" /> -->
<!-- <state type="buildStarted" enabled="true" /> -->
<!-- <state type="responsibilityChanged" enabled="true" /> -->
<!-- <state type="buildSuccessful" enabled="true" /> -->
<state type="buildFailed" enabled="true" />
<!-- <state type="beforeBuildFinish" enabled="true" /> -->
</states>
</template
</templates>
</webhook-template>
</webhook-templates>
When variables are used in JSON template, special characters ("
, {}
) are not escaped which may lead to invalid payload. Is there a way to escape them, like ${escape(variable)}
?
I know there is ${sanitize()}
, but couldn't find any information on what it actually does.
So that user's can report issues and easily identify plugin version. As per comment in #29
Webhooks are processed serially and synchronously. The build "runs" until the listeners complete.
If a webhook takes a long time to process (eg, timeout connecting to the server) it holds up the build.
Should consider using a thread pool and/or doing requests asynchronously somehow.
Is it possible for tcwebhooks to report (post) more details than the standard build related information. I’m looking for a way to get couple more information like start time, end time, number of test cases, pass count, fail count etc. These informations are available if we hit the rest url (https://teamcity-server.com/app/rest/builds/id:12345) provided by teamcity for a given build run.
Since TC 9.0.5 and 9.1 the plugin stopped working
I updated it to 0.9.29.63 and I still don't see any HTTP Post done on my HTTP Listener.
I had it configured to work with https://www.runscope.com and there also I don't see anything happening till I updated
Any idea?
Thanks!
Using the property ${buildStatusHtml} as webhook.body when using Tailored JSON mode (e.g. {“text”:”${buildStatusHtml}”}) will produce a malformed JSON object, since the ${buildStatusHtml} property is not escaped.
void changesLoaded(@NotNull
SRunningBuild build)
Called when changes for a newly started build has been loaded
Parameters: build - build, whose changes are loaded
XML templates are not distributed with a tcWebHooks release. Java templates are.
The current example XML template for Flowdock should be converted into a Java one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.