-
Notifications
You must be signed in to change notification settings - Fork 370
[JENKINS-33161] Customized PR build behavior #60
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
} else if (revision instanceof PullRequestSCMRevision) { | ||
return ((PullRequestSCMRevision) revision).getPullHash(); | ||
} else { | ||
throw new IllegalArgumentException("did not recognize " + revision); |
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.
By keeping a reasonable representation of the SCMRevision
s to begin with, we avoid the need to try to reconstruct what we just built.
private static final long serialVersionUID = 1; | ||
|
||
private final PullRequestAction metadata; | ||
private Boolean merge; | ||
private final boolean trusted; |
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.
Defaulting to false for old settings to be on the safe side. Only practical impact should be that PRs filed before the upgrade will start using Jenkinsfile
from the base branch if you upgrade and then push more commits, even when the PR should have been trusted. I think this is an acceptable price to pay for fixing up the metadata to store this field where it makes more sense, so that we do not need to recheck trusted status on every commit.
…ion." This reverts commit 6ce16b1. FindBugs is not happy with my simplification!
Combinations to be tested include:
|
continue; // not doing this combination | ||
} | ||
if (buildForkPRUnmerged) { | ||
branchName += "-merged"; // make sure they are distinct |
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.
The contrary seems more natural (as most users will want the merged commit to be built). PR-23
for merged, and PR-23-head
for unmerged, for example.
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 have no strong opinion about naming (in particular whether -head
is more or less intuitive than -unmerged
), but felt that having one job mention the merge flag and the other not mention it would be confusing.
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.
Don't invent custom termins like ghprb did, just name as it is in API, head
merge
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.
head
vs. merge
would be OK too. I am not particularly moved by the argument of consistency with the terminology used in the API because (AFAICT) there is no mention in user documentation of virtual merge commits or the like.
“Head branch” vs. “base branch” are used (briefly), so users could probably guess that merge
refers to a merge of the two, whereas head
does not.
Log messages seems misleading when using merged and unmerged PRs:
This is for this PR: amuniz/maven-helloworld#3 I understand that the first log is for the unmerged state and the second one for the merged state. But Adding some additional information would be nice. LGTM so far. |
Yeah the indexing log needs some fine-tuning after this change. I take it you tried running this? And did not find any serious bugs so far? Unfortunately it is time-consuming to try different combinations by hand. For example, IIRC prior to this PR, if a PR were unmergeable Jenkins would actually build a merge commit—between the branch head and the last base branch commit it merged cleanly with! Which certainly smells like a bug, albeit arguably in the GitHub API. But without an automated test suite (like #55) these kinds of corner cases are likely to regress and stay broken for months. |
Yes, I did.
Nop, it worked fine, however I didn't test all corner cases, only the ones that came to my mind in that moment. |
…ean; null is only in the field type for the benefit of readResolve.
@jglick how you got such number imports? |
Looks promising /cc @rguevara84 |
/** Whether to build PRs filed from a fork, where the build is of the merge with the base branch. */ | ||
private @Nonnull Boolean buildForkPRMerge = DescriptorImpl.defaultBuildForkPRMerge; | ||
/** Whether to build PRs filed from a fork, where the build is of the branch head. */ | ||
private @Nonnull Boolean buildForkPRHead = DescriptorImpl.defaultBuildForkPRHead; |
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.
NIT ... I'm after seeing these build*
flags together in a few places in the PR. Seems like they are all closely related and could be encapsulated into a type of some sort.
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.
See the TODO comment in GitHubSCMNavigator
.
🐝 insofar as I get it Made a few minor comments. |
Nice! Do you have any estimate when this will be in the stable release? |
Well technically nothing is blocking me from releasing it in the next hour, though @recena expressed interest in doing some manual testing and I suspect he has no time to do it today because of other obligations. @tfennelly saw your comments, some would be good topics for cleanups, though I am hesitant to do nonessential code changes now since it would require another round of sanity checks. |
@jglick Is it urgent to merge this PR? |
@recena This PR is very important. Especially because pipeline is not compatible with the ghprb plugin. This will allow people to build PRs with pipelines enabled without essentially building all the branches all the time, which is a waste of resources (for most non-trivial repos). @jglick Thanks for all the awesome work! |
@shauvik I know what the PR means 😄 I'm co-maintainer of this plugin. |
JFYI https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Integration+Plugin compatible long time ago even when there no branch-source-plugin. |
@recena Sorry, I didn't mean to offend you. Just that I'm very excited for this PR to make it in :-) |
@shauvik Don't worry. What I meant is this change is important and needs to be tested and documented. |
Great work! @recena did you have time to test? We also want to build origin Pull Requests so it would be great if this moves to the stable release 😎 |
This seems to also fix JENKINS-34728. |
LOGGER.log(Level.FINE, "{0}/commit/{1} {2} from {3}", new Object[] {repo.getHtmlUrl(), revision, state, url}); | ||
repo.createCommitStatus(revision, state, url, message, "Jenkins"); | ||
repo.createCommitStatus(revision, state, url, message, "Jenkins job " + job.getName()); |
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 causes issues right now as it's not possible to require Jenkins status checks to pass anymore without GitHub. It relies on the name being consistent across checks, which isn't possible when the check name is always changing.
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 see this issue has already been filed as JENKINS-36574.
Can this be released? It looks like the work has been completed. |
* Log warnings for caught GitLabApiExceptions * Switch class loggers from org.slf4j to java.util.logging * Fix more exception logging
JENKINS-33161 and probably also fixes JENKINS-33237 by not relying on more exotic details of the GitHub API. Supersedes #36.
SCMRevision
s@reviewbybees