-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Build-trigger-54] Sending a confirmation email to the person that tr…
…iggered the build
- Loading branch information
Showing
5 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.jboss.set; | ||
|
||
import io.quarkus.mailer.Mail; | ||
import io.quarkus.mailer.Mailer; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import org.jboss.set.model.json.BuildJMSTriggerPayload; | ||
|
||
import java.util.List; | ||
|
||
@ApplicationScoped | ||
public class EmailService { | ||
|
||
@Inject | ||
Mailer mailer; | ||
|
||
public void sendMail(BuildJMSTriggerPayload payload) { | ||
String project = payload.gitRepo.substring(payload.gitRepo.lastIndexOf('/') + 1); | ||
String subject = "[Build Trigger] Build of the " + capitalizeFirstLetter(project) + " (version " + payload.projectVersion + ") requested"; | ||
String htmlText = "<p>Request to build <b>" + payload.gitRepo + "</b> in version <b>" + payload.projectVersion + "</b> " | ||
+ "was successfully sent to the productization team using the following parameters:</p>" | ||
+ "<ul>" | ||
+ "<li><b>Tag:</b> " + payload.tag + "</li>" | ||
+ "<li><b>Repository:</b> " + payload.gitRepo + "</li>" | ||
+ "<li><b>Version:</b> " + payload.projectVersion + "</li>" | ||
+ "<li><b>Commit:</b> " + payload.commitSha + "</li>" | ||
+ "<li><b>Streams:</b> " + payload.streams + "</li>" | ||
+ "</ul>" | ||
+ "<p>Report any issues or share suggestions using our " | ||
+ "<a href=\"https://github.com/jboss-set/build-trigger/issues\">GitHub Repository</a>.</p>" | ||
+ "<p>This is an automated Build Trigger message, please do not respond!</p>"; | ||
|
||
|
||
mailer.send(new Mail() | ||
.setSubject(subject) | ||
.setHtml(htmlText) | ||
.setTo(List.of(payload.email))); | ||
} | ||
|
||
private String capitalizeFirstLetter(String input) { | ||
if (input == null || input.isEmpty()) { | ||
return input; | ||
} | ||
return Character.toUpperCase(input.charAt(0)) + input.substring(1); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/jboss/set/exception/BuildTriggerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jboss.set.exception; | ||
|
||
public class BuildTriggerException extends RuntimeException { | ||
public BuildTriggerException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters