-
Notifications
You must be signed in to change notification settings - Fork 136
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
Implement setters instead of constructor for optional parameters #246
Implement setters instead of constructor for optional parameters #246
Conversation
I have now tested this build on my Jenkins and it still works for me. So it does not seem to break anything at least. But I cannot verify whether this actually makes the parameters optional as intended, but it should... |
@westarne it does not break already configured instances? I'll try to test it on my jenkins instance on weekend |
I've tested this via manually replacing the old *.jpi in the plugins folder, so that worked without changing anything configured. I'm not sure if this would work via the usual install process as well, but I think it should. |
sounds good |
I believe this change will make it possible to use However, I'm concerned that this PR appears to be changing more code than necessary. In particular, it should not be adding extra settings. It's better to keep the configuration to the minimum. Even some of the existing overrides don't make sense to me. For instance, "Override project key". Why would anyone do it? And this PR is adding "Build Status". Why would anyone use anything but the actual build result? In any case, adding new user interface should be a separate PR, with a separate justification. |
Both project key and build status are useful and already implemented and merged from different previous issues.
You can this way use the custom buildStatus for example to say that the build step was successful and the test step is in progress. By setting the buildStatus to succesful once you could otherwise never push a "in progress" anymore after that. But as i said, both were implemented before and not in this PR. |
Yes, that's true, override project key and build status were implemented before |
src/main/resources/org/jenkinsci/plugins/stashNotifier/StashNotifier/config.jelly
Show resolved
Hide resolved
I just saw that there is a merge conflict to be resolved. So let me ask what is the current state of this pull request and the next steps? |
On #245 people report problem is gone when they use |
I've resolved the conflicts. In my opinion this change could fix the issue #245. But I was not able to really test this because I could not reproduce the initial issue. It'd great if someone could test this manually (e.g. with the provided .hpi) who is able to reproduce the initial issue. In general this should not create additional issues either way even if it does not fix #245 but testing it in integration first is still important I think. |
@westarne Do you know I suggest to run it, install the "Pipeline: Declarative" plugin and try a Jenkinsfile like this:
You should be able to reproduce the issue with this pipeline on the current |
Thank you for this advice, I was able to reproduce the original issue with this. And it seems to be resolved with this pull request. |
return considerUnstableAsSuccess; | ||
@DataBoundSetter | ||
public void setStashServerBaseUrl(String stashServerBaseUrl) { | ||
this.stashServerBaseUrl = stashServerBaseUrl != null && stashServerBaseUrl.endsWith("/") |
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.
StringUtils#stripEnd could be used.
Implemented the proposed optimizations |
this.prependParentProjectKey = prependParentProjectKey; | ||
this.disableInprogressNotification = disableInprogressNotification; | ||
this.considerUnstableAsSuccess = considerUnstableAsSuccess; | ||
StashNotifier( |
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.
I am thinking if the number of constructors can be reduced even more? Is this one really required?
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.
I'm not sure about that, and neither am I that the test cases existing as well as the ones I can do locally cover all potential use cases. So I've kept it to be on the safe side.
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.
But this is a new one and another one has been removed.
In other plugins it's often handled the way to keep all old constructors for backward compatibility and annotate them with @Deprecated
. That's something the maintainers should decide.
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.
Oh you're right. Then I'm not totally sure, what the constructor was meant for. I think it's just the old DataBoundConstructor
without all of the optional parameters. So I could just move the logic in the no-argument constructor.
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.
Was some time out of the country and noticed that I did not push the change before. Done that now.
Hello, I guess this might also fix the following issue : #266 Is there anything preventing this PR from being merged ? Kind regard, |
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.
This is usually best practice for Jenkins plugins and follows JCasC recommendations as well.
At the moment I think I can accept this PR, but this should be updated |
@westarne a lot of compilation errors |
never merge on the git website, noted. Was just missing a |
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.
LGTM 👍
Thanks @westarne . I'll try try to release this as soon as I can |
Concerning #245
I was not able to reproduce the original issue, but comparing with other plugins this might do the trick. For now this was not tested by me on an actual Jenkins and I could only test if it works for me as it did before. It would be great if someone, for whom the v1.20 is failing, could test this build. (@adrian-at-dmi, @tschlue, @r4d1um)
If you are not able to build this plugin (and you trust me), here is a locally built .hpi:
stashNotifier.zip