Build features: Email Notifier - %teamcity.build.triggeredBy.username%
General email notifications are setup and working (2023.05.04) but we have 1 Personal build plan that instead of using the Notification Rules (either Inherited or Own rules) I'd rather use the Build Features - Email Notifier in the build plan so that I can notify just the user that triggered the build that it is started/complete.
I'm setting the only email address to notify as → %teamcity.build.triggeredBy.username% which does result in a valid email address but emails are not being sent out for normal users but it does work for me (admin). I don't have any other email notifications turned on that will impact this build plan so can't figure out why I get emails when I trigger this plan but no one else does.
Attachment: Upload id: 2023_10_05_292wi74oARvXYN11vkUK3A (file: EmailNotifier.PNG)
Please sign in to leave a comment.
Hello Jason,
When other users trigger the build, what are their usernames? Are they valid email addresses?
You may enable debug-notifications logging preset and have any user who has this problem trigger the build in question, then check the relevant logs in the
teamcity-notifications.log
file. In case of any doubts, please feel free to share the log file with me so I will check further.Yes, everyone's username is their email and they are valid - as I mentioned, they do get notified for other build plans that are setup with notifications based on their group or if they add their own notification rules. (I've asterisk'd email addresses below)
Here are a few relevant lines from the notifications log when another user runs the plan - it always says “Selected 0 users …” :
[2023-10-06 14:20:06,693] DEBUG - cationListener.IDE_Notificator - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Enclave - Personal build plans / Full Game Build with deploy options - Personal Build {id=Enclave_EnclavePersonalBuildPlans_FullConsoleBuildWithDeployPersonalBuild/bt23} and project Enclave / Enclave - Personal build plans {id=Enclave_EnclavePersonalBuildPlans, internal id=project3} (including)
[2023-10-06 14:20:06,693] DEBUG - wareNotificationListener.email - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Enclave - Personal build plans / Full Game Build with deploy options - Personal Build {id=Enclave_EnclavePersonalBuildPlans_FullConsoleBuildWithDeployPersonalBuild/bt23} and project Enclave / Enclave - Personal build plans {id=Enclave_EnclavePersonalBuildPlans, internal id=project3} (including)
[2023-10-06 14:20:06,693] DEBUG - cationListener.jbSlackNotifier - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Enclave - Personal build plans / Full Game Build with deploy options - Personal Build {id=Enclave_EnclavePersonalBuildPlans_FullConsoleBuildWithDeployPersonalBuild/bt23} and project Enclave / Enclave - Personal build plans {id=Enclave_EnclavePersonalBuildPlans, internal id=project3} (including)
[2023-10-06 14:20:06,693] DEBUG - tificationListener.WindowsTray - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Enclave - Personal build plans / Full Game Build with deploy options - Personal Build {id=Enclave_EnclavePersonalBuildPlans_FullConsoleBuildWithDeployPersonalBuild/bt23} and project Enclave / Enclave - Personal build plans {id=Enclave_EnclavePersonalBuildPlans, internal id=project3} (including)
When I run the plan, it doesn't list me right after the “Usernames:” part of the log message but it then goes into the details of the email message and sends it (I cut out some lines but then you can see it has my address in the To:) :
[2023-10-06 13:54:34,619] DEBUG - cationListener.jbSlackNotifier - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Build/Cook/Validation/MapCheck Warning Check (Win64 build) {id=Enclave_CookWarningPs5build/bt9} and project Enclave {id=Enclave, internal id=project1} (including)
[2023-10-06 13:54:34,619] DEBUG - tificationListener.WindowsTray - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Build/Cook/Validation/MapCheck Warning Check (Win64 build) {id=Enclave_CookWarningPs5build/bt9} and project Enclave {id=Enclave, internal id=project1} (including)
[2023-10-06 13:55:54,988] DEBUG - cationListener.IDE_Notificator - Selected 0 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Enclave - Personal build plans / Full Game Build with deploy options - Personal Build {id=Enclave_EnclavePersonalBuildPlans_FullConsoleBuildWithDeployPersonalBuild/bt23} and project Enclave / Enclave - Personal build plans {id=Enclave_EnclavePersonalBuildPlans, internal id=project3} (including)
[2023-10-06 13:55:54,991] DEBUG - wareNotificationListener.email - Selected 1 users with matching notification rules for event BUILD_FINISHED_SUCCESS in build type Enclave / Enclave - Personal build plans / Full Game Build with deploy options - Personal Build {id=Enclave_EnclavePersonalBuildPlans_FullConsoleBuildWithDeployPersonalBuild/bt23} and project Enclave / Enclave - Personal build plans {id=Enclave_EnclavePersonalBuildPlans, internal id=project3} (including); Usernames:
[2023-10-06 13:55:55,081] DEBUG - ation.email.SMTPEmailTransport - DEBUG: setDebug: Jakarta Mail version 1.6.7
<… snip …>
[2023-10-06 13:55:55,537] DEBUG - ation.email.SMTPEmailTransport - MAIL FROM:<teamcity@******games.ca>
[2023-10-06 13:55:55,556] DEBUG - ation.email.SMTPEmailTransport - 250 2.1.0 Sender OK
[2023-10-06 13:55:55,556] DEBUG - ation.email.SMTPEmailTransport - RCPT TO:<jason@*****games.ca>
[2023-10-06 13:55:55,571] DEBUG - ation.email.SMTPEmailTransport - 250 2.1.5 Recipient OK
[2023-10-06 13:55:55,571] DEBUG - ation.email.SMTPEmailTransport - DEBUG SMTP: Verified Addresses
I know the %teamcity.build.triggeredBy.username% is set correctly in the build as I also add a comment to the build through the rest api when it's complete and it shows correctly:
Hello Jason,
May I ask you to add the following internal property?
This should make TeamCity log some extra info each time notification rules are processed, including the ones that are generated on the fly for the Notifications build feature. Once it is added (no restart is needed), can you please have any affected user rerun the build and share the log again?
I have updated captures, how do I add an attachment? (I recall an interface to add attachment when starting the post but don't see anything to add now)
You may use uploads.jetbrains.com for sharing data with us in a private manner - just let me know the upload ID so I can access the data.
OK, 2 files uploaded - Upload id: 2023_10_11_uEyh84mohGwyVVy4ikLjcy (files: teamcity-notifications_condensed.txt, teamcity-notifications_full.log)
The ‘condensed’ file is where I've pulled out what I believe are all the notification logs associated with 2 runs of the build in question. The first one I initiate and you can see from the logs that the notification feature works and sends me an email. The second run is initiated by another use and it doesn't seem to recognize that the notification feature has been setup.
The ‘full’ file contains all the notifications around the timeframe of the 2 builds I pulled into the condensed file in case I missed anything. (just harder to read with normal notifications for other build plans happening)
Thanks!
I am most sorry about the delayed response here. I have tried to reproduce your issue but the only case when I got the same behavior is when the build in question was a personal build. Given the build configuration name, is there any chance your users are starting their builds as personal ones? I believe Notifications feature ignores such builds.
Yes, this build plan is initiated almost exclusively by users as a personal build. That's why I would like to just have the email notification be sent out to the user that triggered the build.
In that case, if you use any of 2023.05.X versions, you may consider setting up a custom script to send notifications from the build itself via service messages (https://www.jetbrains.com/help/teamcity/service-messages.html#Sending+Custom+Email+Messages). You may specify a build step that will only fire if the build is failing (see https://www.jetbrains.com/help/teamcity/configuring-build-steps.html#Execution+Policy), and it could take the triggeredBy.username as an address property. Would this work for you?
Sounds like that would meet my needs. I'll try that out today or tomorrow. Thanks.
Hi Fedor
I am looking out for the same solution but in my case userid amd email address both are different. Userid is alphanumeric string and email address is completely different.
I want to notify user who has triggered the build in teamcity. can you please help!!
The same setup, as per the latest message from Fedor, should also work for your case. Please let me know if you have additional questions or if you encounter any issues setting it up.
Best regards,
Anton