Coder Social home page Coder Social logo

Comments (16)

netwolfuk avatar netwolfuk commented on June 3, 2024 1

Here are a couple of things you could try. I can't easily get a value that doesn't exist, other than referring to values that are non-existent. However, this means that I can't test both positive and negative scenarios.

In this first example we utilise regex's negative lookahead to look for something that does not contain .+ (which means at least one character). In other words, something that is empty.
${teamcity.build.something.nonexistant} :: ^(?!.+)$

However, this might not work because the template engine (Standard) used by the MS Teams template will actually return UNRESOLVED for any variable it can't resolve. If this was a Velocity template, that would probably have been the correct approach.

With this information, we can actually look for "UNRESOLVED" and you might have better success.
${teamcity.build.something.nonexistant} :: UNRESOLVED

In my testing this appears to work.

So for you, you could try ${teamcity.build.branch} :: UNRESOLVED

eg,

image

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

Firstly. thank you for your excellent bug report. It has everything I needed to check.

I did as you indicated and created a Quick Filter for default branch.
When run, it works correctly.

Can I ask you if the error 702 above is from an actual running build or from testing the UI somewhere?

My trigger filters looks the same as yours, so I can't see anything that you're doing wrong.

      <trigger-filters>
        <filter value="${branchIsDefault}" regex="true" enabled="true" />
      </trigger-filters>

My version 1.2.5 is built from a different branch so I'll get the officially released one and try again. I'll try to get back to you tomorrow with an update.

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

I now have 1.2.5 release installed but I can't reproduce this issue.
I wondered if it might be because the build needed to fail, but I found a build that fails on main and that still works correctly for me.

image

Can you please check that the VCS is set as having branch support? Does TeamCity show you multiple branches in the UI like this?

image

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

Hi, thanks for your prompt reply !

So, yes the project is showing the multiple branches in the UI,
but I just noticed that the main branch does not show up like the other branches:
image

On other project it shows main there.
Maybe, this is causing the issue...

I'll have a look at the configuration in detail to see if something is missing...

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

Ok, when I look in the parameter tab of one of this build, I see I don't have this one:
teamcity.build.branch.is_default

So, I guess that's why it is failing

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

I have that value, but it's set to false for non-main builds.

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

Thanks for your help.
I think we can close the issue.
The plugin is not responsible for the error. It is really link to my custom build configuration

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

Thanks for the update. I'll close it out. Thanks for using tcWebhooks.

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

I do have a question though:
Is it possible to test if a variable exists with the filter configuration ?
Reading the doc, I didn't find anything...

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

I'm not sure I really understand the question.

Are you asking if the UI can check if a variable exists when we configure the filter?
Or are you referring to other variables? Eg, ones that are defined on the build or payload?

Or perhaps you are asking whether it's possible to check if the variable is defined?

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

Yes, I would like to add a filter in the webhook configuration to check if the teamcity.build.branch is defined

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

What behaviour would you like if the filter does not find the value? Prevent the webhook or send the webhook?

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

I would like to send the webhook only if the variable does not exits.

But, if this is not possible, I will find another way.

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

BTW, you can test this from the Preview & Test tab when editing a webhook. Just choose a build from the history that has or does not have that value set. This might be more convenient than triggering builds all the time.

To test the Filters, you will need to click the "Send Test Webhook for BuildEvent" button. The preview does not test the filters.

image

from tcwebhooks.

jtognazzi avatar jtognazzi commented on June 3, 2024

Checking for UNRESOLVED works !
Thanks for the detailed explanation, for your time and for this plugin !

from tcwebhooks.

netwolfuk avatar netwolfuk commented on June 3, 2024

That's fantastic. Thanks for the update.

from tcwebhooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.