-
Notifications
You must be signed in to change notification settings - Fork 97
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
JENKINS-31843 - Merge build parameter values when "Build is parameterized" #34
base: master
Are you sure you want to change the base?
Conversation
…ized". Give precedence to values supplied from "Build is parameterized" (overrides)
@reviewbybees |
Needs several unit tests. |
regards |
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
@oleg-nenashev Added tests |
public int compare(ParameterValue o1, ParameterValue o2) { | ||
return o1.getName().compareTo(o2.getName()); | ||
} | ||
}, Iterables.concat(values, paramAction.getParameters())); |
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.
You should check for null before accessing paramAction
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.
@amuniz Added the null check to be safe but struggling to see how 'paramAction' would be null at this stage based on - https://github.com/jenkinsci/rebuild-plugin/blob/master/src/main/java/com/sonyericsson/rebuild/RebuildAction.java#L206
The lack of null checks in the existing code seems to echo this - https://github.com/jenkinsci/rebuild-plugin/blob/master/src/main/java/com/sonyericsson/rebuild/RebuildAction.java#L417
Either that or its just really fragile :)
cheers
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.
Probably you are right, the action will be always set and it's never null, but, in general, I think it's a good practice to check for null the return value of getAction
, since it depends on someone adding that action before (and in some cases even in a separate plugin, which is clearly butterfly effect prone 😄 IMO)
🐝 |
@@ -393,6 +398,110 @@ public void testRebuildSupportedUnknownParameterValue() throws Exception { | |||
page.asText().contains("This is a mark for test")); | |||
} | |||
|
|||
public void testWhenProjectWithExistingParamAndOverridingParamWhenRebuild() | |||
throws Exception { |
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 would suggest to rename this test, I think there's something wrong with the sentence itself and it is not really clear what's the goal of the test, probably something like "newParametersShouldOverrideExistingPatametersIfHaveSameName" or something like that.
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.
changed
🐜 IMHO the classes implemented to support the tests ( |
@varmenise Cleaned up test names and refactored matchers into single matcher taking varargs. RE: "classes implemented to support tests are an overkill" - I would have to disagree when it comes to things like rules and matchers but as you mentioned this is possibly more personal preference / opinion than anything. |
Well, I actually meant that those 3 classes (that could be reduced to 1) were an overkill, but the current cleanup is good to me! so 🐝 |
I think it's better to err on the side of "too many tests" just because you never know. It looks good with all the changes. 🐝 |
Sorry @varmenise I misread that. Blaming this on the early morning and weak coffee ;) |
@Evildethow no worries :) |
@hagzag @shemeersulaiman Could i get a maintainer to look at this? |
User confirmed changes resolved issue using a snapshot version with these changes |
So, what's holding back merging this in? |
@hagzag are you able to merge this? |
@Evildethow The recommendation is to start the e-mail thread in jenkinsci-dev and to Cc mentors there. If there is no response within 2 weeks, you will be eligible to request push permissions to the repo |
That might well fix all of: https://issues.jenkins-ci.org/browse/JENKINS-31730 Apparently it used to work with rebuild plugin 1.21 . Might have been broken by #19 |
I had this pull request applied on top of 1.25 and that solves the issue I was encountering. Maybe the commits can be squashed/rebased and that can get merged? |
370af40
to
316c049
Compare
NOTE: Currently on rebuild if parameters are supplied via "Build is parameterized" then any pre existing parameters are clobbered.