-
Couldn't load subscription status.
- Fork 26
Improve Embeds, Major Refactor/Cleanup #138
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments
src/main/java/nz/co/jammehcow/jenkinsdiscord/util/EmbedUtil.java
Outdated
Show resolved
Hide resolved
Signed-off-by: solonovamax <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I left some comments on things that have to be addressed.
| this.j.assertEqualDataBoundBeans(step, roundtrippedStep); | ||
| } catch (Exception e) { | ||
| fail(); | ||
| throw new RuntimeException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for wrapping this exception in a RuntimeException?
| StringUtils.stripToNull(this.customUsername), | ||
| null, | ||
| null, | ||
| this.dynamicFieldContainer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dynamicFieldContainer fields should also be expanded with env variables.
See lines 200, 202, 206, 210
| if (step.getCustomUsername() != null) { | ||
| wh.setCustomUsername(step.getCustomUsername()); | ||
| } | ||
| protected DiscordPipelineStepExecution(DiscordPipelineStep step, StepContext context) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructor needs @Inject annotation
| embedBuilder.addField(new EmbedField(true, "Branch", branch)); | ||
| } | ||
|
|
||
| String buildResult = Objects.requireNonNull(build.getResult()).toString().toLowerCase(Locale.ENGLISH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the result field from DiscordPipelineStep, not Run.
|
|
||
| String username = EmbedUtil.withFallback(customUsername, "Jenkins"); | ||
| String avatar = EmbedUtil.withFallback(customAvatarUrl, "https://get.jenkins.io/art/jenkins-logo/1024x1024/headshot.png"); | ||
| embedBuilder.setAuthor(new EmbedAuthor(username, avatar, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Username and avatar should also be set on the webhook message to match previous functionality.
Improves embeds and a major refactor/cleanup of basically everything.
This improves embeds based off of the suggestions provided via #27
Here's a list of relevant issues
Here are the changes to the embed:
For the refactors/cleanup:
Testing done
Honestly I have no clue how to do testing with Jenkins plugins. Would love feedback for that if tests are needed, however since there were already basically no tests I felt it wasn't super needed.
Submitter checklist