Skip to content

[WIP] Add an external contributor approval mechanism of Pull Requests - #1556

Open
olamy wants to merge 5 commits into
jenkinsci:masterfrom
olamy:pr-approval
Open

[WIP] Add an external contributor approval mechanism of Pull Requests#1556
olamy wants to merge 5 commits into
jenkinsci:masterfrom
olamy:pr-approval

Conversation

@olamy

@olamy olamy commented Aug 24, 2026

Copy link
Copy Markdown
Member

Description

Adds a new fork PR trust policy: External approval required.

Right now, trusting fork PRs is all-or-nothing (nobody, everybody, contributors,
or write access). This adds a middle ground: fork PRs are discovered as usual, but
each one waits for a person to approve it before it builds. Handy for public repos
where you want CI on fork PRs, but only after someone has taken a look.

How it works

  • Set the fork trust policy to External approval required.
  • A new fork PR shows up as a disabled job marked Pending Approval, and it
    won't build on its own.
  • Someone with Configure permission approves it from the job's Pending
    Approval
    page (or reverts it). Approving enables the job and starts a build.
    The approval is saved next to the job, so it sticks across restarts.

Options

  • Require approval for new commits. the approval only covers the commit you
    approved. If new commits are pushed, the PR goes back to Pending.
  • Auto-approval users. GitHub logins (comma-separated) whose PRs are approved
    automatically. Matched ignoring case, like GitHub does.
  • Auto-approval labels. labels (comma-separated) that approve a PR
    automatically. Checked once, when the PR is first seen.

Screenshots

Configuration

force-ext-approval

Blocked PR

pending-approval

Run approval

pr-approval

Trying it out

  1. In a multibranch project, add Discover pull requests from forks with trust
    set to External approval required.
  2. Open a fork PR and scan. the job should be disabled and marked Pending.
  3. Click Approve on the Pending Approval page. the job builds.
  4. Optional: turn on Require approval for new commits, approve, push a commit.
    it goes back to Pending.
  5. Optional: add your fork login to Auto-approval users. a matching PR builds
    without asking.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify

@olamy
olamy force-pushed the pr-approval branch 4 times, most recently from f88dffe to 6744880 Compare August 24, 2026 11:48
Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
@olamy
olamy marked this pull request as ready for review August 26, 2026 21:04
@olamy
olamy requested a review from a team as a code owner August 26, 2026 21:04
Comment thread pom.xml
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Architecturally this is wrong—branch sources do not depend on project specifics.

Now I recall that I actually started work on this problem a while back but review stalled in discussions about security implications: jenkinsci/scm-api-plugin#180

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correction: a related problem, about PRs specifically changing Pipeline script, which is riskier. Perhaps there should be a unified DX allowing maintainers to permit or deny builds from forks based on whether or not Pipeline script changed; approval of a given commit vs. any commit to that PR; whitelisting of a given author. In the case of GH specifically, there are as I recall several modes available to GHA though I doubt a Jenkins controller could inspect those settings without elevated permissions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, this layering approach is perfectly right.
BUT I would prefer the feature proposed here (it's actually not a feature, but get back on track with what GHA has been proposing for years) to not depend on another change that has been stalled for 3 years.
The idea here is to prevent the execution of any code without approval. (Jenkinsfile or not)
But rather than focusing on the "ideal" technical approach, we could focus on delivering features users have been expecting for years now.
Anyway, I will try a separate plugin approach because my goal here is to have happy users enjoying some interesting features.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But frankly, such a feature should be a natural part of this plugin; users should not have to install anything else.
That's definitely not a user-friendly approach (IMO)

Signed-off-by: Olivier Lamy <olamy@apache.org>
* The job starts out disabled and only builds once an administrator has approved it. Pull
* requests from a trusted login, or carrying a trusted label, are approved for you.
*/
public static class TrustExternalApproval extends GitHubForkTrustPolicy {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No existing code is being changed here AFAICT. So this could be released as a separate plugin for experimental purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants