Skip to content

Access merged pull request in build#139

Open
l3ender wants to merge 10 commits intojenkinsci:masterfrom
l3ender:pr-merges
Open

Access merged pull request in build#139
l3ender wants to merge 10 commits intojenkinsci:masterfrom
l3ender:pr-merges

Conversation

@l3ender
Copy link

@l3ender l3ender commented Jan 24, 2026

Overview

This PR adds the ability to access a pull request that was merged into a PR/branch. Example:

  1. Pull request 123 is merged to master branch.
  2. Build runs on master and wants to be able to access detail for PR 123.

Resolves #1.

Additional detail

This was implemented such that the new mergedPullRequest global variable is available if the following is true:

  1. The newly-added Detect Merged Pull Request trait is added to build's behaviors. This instructs the build to search for a potential merged pull request:

    image
  2. The most recent update to the branch or pull request was due to an upstream pull request being merged.

Testing done

This was manually tested locally with a test repo that references the new features: https://github.com/l3ender/jenkins-pipeline-github-plugin-testing.

The local Jenkins builds were configured with the necessary trait to enable to new feature, both in branch-based and PR-based builds.

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 demonstrate the feature works or the issue is fixed

@l3ender l3ender changed the title Access merged pull request in branch build Access merged pull request build Feb 2, 2026
@l3ender l3ender changed the title Access merged pull request build Access merged pull request in build Feb 3, 2026
@l3ender l3ender marked this pull request as ready for review February 3, 2026 03:01
@l3ender
Copy link
Author

l3ender commented Feb 3, 2026

@aaronjwhiteside or @aaronwalker, would you mind looking at this feature addition? It resolves what was discussed in #1.

Let me know--thanks!

@l3ender
Copy link
Author

l3ender commented Feb 16, 2026

Hello @aaronjwhiteside or @aaronwalker, could you please take a look at this change? Thank you!

@aaronwalker
Copy link
Member

@l3ender let me take a look over the next couple of days. I need to get my head back into this change and the overall goal of the PR

Comment on lines +86 to +91
uri.append('/').append(repoId);
uri.append("/pulls");
uri.append("?state=").append("closed");
uri.append("&sort=").append("updated");
uri.append("&direction=").append("desc");
uri.append("&per_page=").append("10"); // only need to check the most recently closed PRs

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Nice--thank you! Will update.

Copy link
Author

Choose a reason for hiding this comment

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

I've updated and so far, seems to be working. I want to do a bit more testing, though--especially in a repo with a large number of PRs. Specifically, I'm not sure on this behavior:

If the commit is not present in the default branch, it will return merged and open pull requests associated with the commit.

That's definitely a valid scenario (PR is merged outside of the default branch, updating a branch and triggering a build), but I can't quite tell what it means for a pull request to be "associated with the commit" and so want to do a little deeper testing.

Will update here when done--thanks!

@@ -0,0 +1 @@
17

Choose a reason for hiding this comment

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

Seems unrelated to the main change

Copy link
Author

Choose a reason for hiding this comment

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

This is jenv's config file; I added to align with the same in the parent pom.

Would you prefer the change in a different PR? Or added to gitignore?

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.

Identify pull request merge builds

3 participants