tcWebHooks
tcWebHooks copied to clipboard
Allow to select subprojects in webhook configuration
Expected Behavior
Using nested subproject definitions, I would like to define a webhook configuration at the top (e.g. _Root) and select only nested project that we require. In this way, we can reduce duplications in different subproject that use same channel/url
Current Behavior
No possibility to select nested subprojects; only one level of nesting is allowed to share same configuration
Out of interest, how many levels do you have? We typically have about 3 projects deep as maximum, so I am just trying to determine what the ux might look like.
at the moment, bigger nested case on our sistem includes 5 level of nested projects
With our system it is up to 3. Is there any update on this issue?
We are facing the same problems, we want to add a webhook at the root level. Currently we cannot test this as the subprojects are not found at all. Is there any way to get a workaround for the problem apart from adding the webhook in over 50 Projects?
We are currently using TeamCity 2017.2.2
Hi @huehnerlady It looks like you're trying to setup a webhook in a project that has no builds configured. Or are you adding a webhook at the root level?
For me, the root level finds all recent builds. Can you please open the developer console in your browser, and then open the webhook dialog? It should make a rest request to builds?
and load the list of recent builds in all sub-projects.
Just try clarify. @huehnerlady Do you want to have the webhook configured for all sub projects, or do you want to be able to select specific projects, or even specific builds within projects?
Assuming we can get this list of builds working for you, we should be able to configure a filter to prevent the webhook from triggering on certain scenarios.
I'll do some testing and provide an example configuration.
https://github.com/tcplugins/tcWebHooks/wiki/Applying-Filtering-Criteria-To-WebHook-Execution
Currently they need to be edited in the config file, but editing in the UI is on the road map for the 1.2 release.
I have been able to use filters to conditionally trigger a webhook for a specific build and/or project. This is what I did:
- Edit TeamCity parameters in the
_Root
project. For me, the URL was/admin/editProject.html?projectId=_Root&tab=projectParams
- Create a Parameter with the default setting. I created a Parameter called
webhook.my_webhook_enabled
, and set the default value tofalse
Note: Any parameter prefixed with
webhook.
will have the prefix removed when added to the webhook payload. It will therefore be in the payload as simplymy_webhook_enabled
- Create your webhook configuration in the WebHook UI. You can skip this step if you already have a webhook configured.
- Go into Administration | Diagnostics | Browse Data Directory and edit the
plugin-settings.xml
for the project you created the webhook in. Mine was atconfig/projects/_Root/pluginData/plugin-settings.xml
because I created it in the_Root
project. - Find your webhook configuration, and add a
filter
configuration to check for the required parameter. This is what mine looked like:The code block I added is:
If the above matches, the webhook will trigger, otherwise it will be skipped.<trigger-filters> <filter value="${my_webhook_enabled}" regex="^true$" enabled="true" /> </trigger-filters>
- Trigger a build and see that it is skipped in the webhook history.
Navigate to Administration | WebHooks and click the number for "Skipped Events". For me the URL is
/webhooks/history.html?view=skipped
- You should an event like this, indicating that the webhook was skipped.
- To enable this webhook for certain builds or whole projects, override the Parameter value in a Build or Project configuration. I created a Build Parameter called
webhook.my_webhook_enabled
, and set the default value totrue
. - Trigger a build for a build that will have this new parameter defined. You should see the webhook sent in the history of "Succesful Events". For me the URL is
/webhooks/history.html?view=ok
You can go into any build or project and define this parameter to override it. If the parameter is not defined, it will inherit the one from the _Root
project.
Note: It appears that using the test button in the webhook UI ignores the filter match, and sends the webhook anyway. This is a bug, although you can't actually see that, due to the builds list not being populated correctly.
@huehnerlady Do you have your teamcity located at a different context in Tomcat? eg, something like http://your_server/teamcity/
Perhaps that is why the build list is not loading correctly. Can you please send a screen shot of the browser console trying to load the builds?locator=...
URL?