-
Notifications
You must be signed in to change notification settings - Fork 27
Create dedicated Cause for MCP #84
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
Conversation
|
🤔 Now I realize that keeping also the username who is using the MCP server would be important. I'll modify the PR. |
moved it to draft for now |
> Medium: A null pointer returned by a method risks being dereferenced in new io.jenkins.plugins.mcp.server.extensions.DefaultMcpServer$MCPCause() [io.jenkins.plugins.mcp.server.extensions.DefaultMcpServer$MCPCause, io.jenkins.plugins.mcp.server.extensions.DefaultMcpServer$MCPCause] Dereferenced at DefaultMcpServer.java:[line 101] Known null at DefaultMcpServer.java:[line 101] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
| job.checkPermission(Item.BUILD); | ||
| Cause.UserIdCause userIdCause = new Cause.UserIdCause(); | ||
| CauseAction action = new CauseAction(userIdCause); | ||
| CauseAction action = new CauseAction(new MCPCause()); |
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.
could be even more simple :)
Cause.UserIdCause userIdCause = new Cause.UserIdCause();
CauseAction action = new CauseAction(userIdCause){
@Override
public String getShortDescription() {
if (userIdCause.getUserId() != null) {
return "Triggered via MCP Server by " + userIdCause.getUserId();
}
return "Triggered by MCP Server";
}
};
Bear in mind getShortDescription is deprecated so if use by other plugins it may change (not used anymore) in the future.
| job.checkPermission(Item.BUILD); | ||
| Cause.UserIdCause userIdCause = new Cause.UserIdCause(); | ||
| CauseAction action = new CauseAction(userIdCause); | ||
| CauseAction action = new CauseAction(new MCPCause()); |
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.
CauseAction accepts multiple causes.
You can add both UserId and new mcp causes.
This is useful for the end user to understand that the call was trigger through this plugin's code and not some manual user intervention. And among others, it allows plugins like buildtriggerbadge to offer custom badges.
Testing done
Before this change, if you trigger the build through the MCP Server, this would show this (because the code was using "UserIdCause")
With this change
Submitter checklist