Skip to content

Conversation

@solonovamax
Copy link

@solonovamax solonovamax commented Oct 20, 2024

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:

  • Move everything to embed fields
  • Shortened the artifacts list by using inline links
  • Some other misc cleanup

For the refactors/cleanup:

  • Remove code for discord webhook, instead use discord-webhooks
  • Move all the code for building embeds to a shared util class

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

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Copy link

@Andre601 Andre601 left a comment

Choose a reason for hiding this comment

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

Just some comments

Signed-off-by: solonovamax <[email protected]>
Copy link

@KocproZ KocproZ left a 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);
Copy link

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,
Copy link

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) {
Copy link

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);
Copy link

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));
Copy link

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.

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.

Suggestions: Improve display of webhook Feature Request: Parity with pipeline implementation

3 participants