hfontanez
hfontanez

Reputation: 6188

Is there a way to set a custom condition for Office 365 webhook notification in Jenkins?

I currently have several Jenkins jobs that will send a notification to a channel on Microsoft Teams at the conclusion of the test. The intended goal was to send these notification during deployments. The job is configured as illustrated on the image below enter image description here

Ideally, I would like to include a condition that will send this notification if the targeted environment is a production environment and not a test environment. This way, I won't be spamming that Teams channel with notifications while troubleshooting issues.

I tried setting up a macro as illustrated below enter image description here

When the environment parameter value didn't match, the job concluded and nothing was logged in the console (notification was not sent). When the value did match, the following message showed up in the console [Office365connector] Matched template '${ENV, var="environment"}' for webhook with name ... where the name matched the environment from the Maven command I used for the test run. However, the notification was not sent to the Microsoft Teams channel. Obviously, this is wrong. I am assuming the reason for this is that ENV is not defined.

In summary, I need help setting up this macro. The reference I used for how to set up the macro is found here.

Upvotes: 0

Views: 1290

Answers (1)

hfontanez
hfontanez

Reputation: 6188

My original macro setup works. The reason why it was not sending the notification was because the check box for "Notify Repeated Failure" was not checked and the previous jobs had failed before.

Once I checked that option, it only sends the notification when the targeted environment matches the value (i.e. "prod").

Upvotes: 2

Related Questions