You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins插件推荐:如何获取GitHub Enterprise新增/变更PR信息

Hey there! I’ve worked with Jenkins integrations for GitHub Enterprise quite a bit, so let’s tackle your questions step by step.

Here are the most reliable, easy-to-use plugins tailored for tracking new or updated pull requests on GitHub Enterprise:

  • GitHub Pull Request Builder Plugin: This is the go-to plugin for PR-specific workflows. It supports both polling and webhook triggers to detect new PRs, code updates in existing PRs, or status changes (like reopened PRs). It’s fully compatible with GitHub Enterprise’s API and permission models.
  • GitHub Plugin: Think of this as the foundational plugin—it handles authentication between Jenkins and your GitHub Enterprise instance, enables repository access, and powers the core functionality that most PR-focused plugins rely on. It can also be configured to poll for PR state changes directly.
  • Generic Webhook Trigger Plugin: If you need custom logic (like triggering builds only when PRs meet specific criteria), this plugin lets you listen to GitHub Enterprise webhook events for PRs. It’s more flexible than basic polling and reduces unnecessary Jenkins job runs.
How to Fetch New/Updated PRs from GitHub Enterprise Using Jenkins Plugins

Let’s walk through a practical setup using the GitHub Pull Request Builder Plugin (the most straightforward option):

  1. Install & Configure Base Plugins

    • First, install both the GitHub Pull Request Builder Plugin and GitHub Plugin via Jenkins’ Plugin Manager.
    • Head to Jenkins’ global configuration, find the GitHub Enterprise section, and enter your instance’s URL. Add valid credentials (a personal access token with repo and read:org permissions works best) to authenticate Jenkins with your GitHub Enterprise account.
  2. Set Up Trigger for PR Changes

    • Polling Approach: In your Jenkins job’s configuration, go to the Build Triggers section, check "GitHub Pull Request Builder". Set a polling schedule (e.g., H/15 * * * * to check every 15 minutes) and specify the repository, PR states (like "open") you want to monitor.
    • Webhook Approach (More Efficient): Skip polling entirely by setting up a webhook in your GitHub Enterprise repository. Go to the repo’s Settings > Webhooks, add a new webhook with the payload URL your-jenkins-url/ghprbhook/, and select the "Pull request" event (include opened, synchronize, reopened events). This way, Jenkins gets notified immediately when a PR changes.
  3. Access PR Details in Your Build

    • The plugin injects useful environment variables into your job, such as:
      • ghprbPullId: The unique ID of the PR
      • ghprbSourceBranch: The source branch of the PR
      • ghprbTargetBranch: The target branch the PR is merging into
    • To get full PR details (like title, description, or commit history), you can call the GitHub Enterprise API in your build script using these variables:
      curl -H "Authorization: token YOUR_GHE_ACCESS_TOKEN" https://your-ghe-domain/api/v3/repos/your-org/your-repo/pulls/$ghprbPullId
      
  4. Filter PRs (Optional)

    • If you only want to act on specific PRs, configure the plugin’s filter settings—you can restrict builds to PRs with certain labels, from specific users, or that match custom commit message patterns.

内容的提问来源于stack exchange,提问作者osexp2000

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:00:39