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

[Build-trigger-54] Sending a confirmation email to the person that triggered the build #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khermano
Copy link
Collaborator

resolves #54

@@ -27,10 +32,22 @@ public class BuildTrigger {
public void triggerBuild(BuildJMSTriggerPayload payloadMessage) {
try (JMSContext context = connectionFactory.createContext(Session.AUTO_ACKNOWLEDGE)) {
context.createProducer().send(context.createTopic(triggerTopic), objectMapper.writeValueAsString(payloadMessage));
logger.infof("Build message successfully sent to UMB for repository: %s, version: %s",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> "Build message sent to UMB..."

@@ -27,10 +32,22 @@ public class BuildTrigger {
public void triggerBuild(BuildJMSTriggerPayload payloadMessage) {
try (JMSContext context = connectionFactory.createContext(Session.AUTO_ACKNOWLEDGE)) {
context.createProducer().send(context.createTopic(triggerTopic), objectMapper.writeValueAsString(payloadMessage));
logger.infof("Build message successfully sent to UMB for repository: %s, version: %s",
payloadMessage.gitRepo, payloadMessage.projectVersion);
if (payloadMessage.email != null && !payloadMessage.email.isBlank()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the indentation alright for this if clause?

} catch (JMSRuntimeException e) {
logger.errorf("Failed to send build message to UMB for tag: %s. Exception: %s",
payloadMessage.tag, e.getMessage());
throw new BuildTriggerException("Failed to send build message to UMB due to internal error: " + e.getMessage(), e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> "Failed to send build message to UMB due to: ..."

throw new RuntimeException("Failed to serialize BuildJMSTriggerPayload to JSON: " + e.getMessage(), e);
throw new BuildTriggerException("Failed to serialize BuildJMSTriggerPayload to JSON: " + e.getMessage(), e);
} catch (JMSRuntimeException e) {
logger.errorf("Failed to send build message to UMB for tag: %s. Exception: %s",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two similar loggers, one on L35, saying that the build was sent and the other here, saying that it wasn't sent. Both of them are including different information. Should be unified

Mailer mailer;

public void sendMail(BuildJMSTriggerPayload payload) {
String subject = "Request to build project: " + payload.gitRepo + ", version: " + payload.projectVersion + " successfully sent";
Copy link
Collaborator

@petrberan petrberan Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a way too long for a subject. I'd go with something like [Build Trigger] Build of <component>, version <version> requested"


public void sendMail(BuildJMSTriggerPayload payload) {
String subject = "Request to build project: " + payload.gitRepo + ", version: " + payload.projectVersion + " successfully sent";
String text = "Request to build project: " + payload.gitRepo + ", version: " + payload.projectVersion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request to build <component> in version <version> was successfully sent to a productization team using following parameters:

Tag:
Repository:
Version:
Commit:
Streams:

Report any issues or share suggestions using our GitHub Repository

This is an automated Build Trigger message, please do not respond!

.setText(text)
.setTo(List.of(payload.email)));

logger.infof("Sending mail to %s about successful request to build project.\n Subject: %s\n Text: %s", payload.email, subject, text);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perhaps way too much logging given the fact that we can check the email itself.

logger.infof("Sending mail to %s about successful request to build project", payload.email);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to BuildTrigger and modified it a bit because we are not the ones receiving the email. The person who asked for a build is receiving the email and we should get at least a notification about sending this email so we know everything went well. Or what did you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that the content of the email can be verified either by sending the email to us or said person can redirect the email to us as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I removed that.

", version='" + projectVersion + '\'' +
", commitSha='" + commitSha + '\'' +
", streams='" + streams + '\'' +
return "BuildJMSTriggerPayload{" + "\n" +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The email would probably require some formatting method to somewhat prettify the data here

@petrberan petrberan requested a review from xjusko October 23, 2024 11:30
@khermano khermano force-pushed the build-trigger-54_from_main branch 3 times, most recently from 7e52126 to 3fb2fbf Compare October 23, 2024 13:20
Mailer mailer;

public void sendMail(BuildJMSTriggerPayload payload) {
String subject = "[Build Trigger] Build of " + payload.gitRepo + ", version: " + payload.projectVersion + " requested";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a component, but a git repo :) The line (as well as the one below) should look like "[Build Trigger] Build of Resteasy, version 3.2.1 requested" as opposed to "[Build Trigger] Build of https://github.com/resteasy/Resteasy/, version 3.2.1 requested"

Or similar formatting, looking at it I'm not a fan of the ",version x.x.x requested" part. Do you have any idea how to change it?

We might want to add project property for the BuildInfo as we'll be using it here and in the CU creation as well. For now, let's add

String project = payload.gitRepo.substring(payload.gitRepo.lastIndexOf('/') + 1)

Copy link
Collaborator

@xjusko xjusko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

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

Successfully merging this pull request may close these issues.

Send a confirmation email to the person that triggered the build
3 participants