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

Allow to select subprojects in webhook configuration #117

Open
alexkaos87 opened this issue Sep 30, 2018 · 9 comments
Open

Allow to select subprojects in webhook configuration #117

alexkaos87 opened this issue Sep 30, 2018 · 9 comments

Comments

@alexkaos87
Copy link

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

@netwolfuk
Copy link
Member

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.

@alexkaos87
Copy link
Author

at the moment, bigger nested case on our sistem includes 5 level of nested projects

@huehnerlady
Copy link

huehnerlady commented Aug 26, 2020

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?

image
image

We are currently using TeamCity 2017.2.2

@netwolfuk
Copy link
Member

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.

image

@netwolfuk
Copy link
Member

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?

@netwolfuk
Copy link
Member

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.

@netwolfuk
Copy link
Member

netwolfuk commented Aug 27, 2020

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.

@netwolfuk
Copy link
Member

netwolfuk commented Aug 27, 2020

I have been able to use filters to conditionally trigger a webhook for a specific build and/or project.
This is what I did:

  1. Edit TeamCity parameters in the _Root project.
    For me, the URL was /admin/editProject.html?projectId=_Root&tab=projectParams
  2. Create a Parameter with the default setting. I created a Parameter called webhook.my_webhook_enabled, and set the default value to false
    image
    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 simply my_webhook_enabled
  3. Create your webhook configuration in the WebHook UI. You can skip this step if you already have a webhook configured.
  4. Go into Administration | Diagnostics | Browse Data Directory and edit the plugin-settings.xml for the project you created the webhook in.
    Mine was at config/projects/_Root/pluginData/plugin-settings.xml because I created it in the _Root project.
  5. Find your webhook configuration, and add a filter configuration to check for the required parameter.
    This is what mine looked like:
    image
    The code block I added is:
      <trigger-filters>
        <filter value="${my_webhook_enabled}" regex="^true$" enabled="true" />
      </trigger-filters>
    
    If the above matches, the webhook will trigger, otherwise it will be skipped.
  6. 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
  7. You should an event like this, indicating that the webhook was skipped.
    image
  8. 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 to true.
  9. 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
    image

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.

@netwolfuk
Copy link
Member

netwolfuk commented Aug 27, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants