jenkins - aetas-github-training/Support GitHub Wiki

Jenkins

Building pull requests

Preparation

  1. Ensure that the GitHub Enterprise instance can access the Jenkins instance by URL or IP
  2. Create a user in GitHub Enterprise that will be dedicated to operating as Jenkins or leverage an existing user.
  3. Create a personal access token for this user with repo and repo:status scopes
  4. Grant the Jenkins user admin access to applicable repositories using teams

Adding/managing plugins

  1. Select Manage Jenkins menu.
  2. Click Manage Plugins.
  3. Install the GitHub plugin and the GitHub Pull Request Builder. This will cause the GitHub API Plugin to be installed as a dependency.
  4. Ensure all three plugins are enabled and that Jenkins has restarted.

Configuring account

  1. Select Manage Jenkins menu.
  2. Select Configure System link.
  3. In the GitHub Pull Request Builder section:
  • Add the appropriate API URL.
  • Under Credentials, click
    • Change kind to Secret Text
    • Enter the personal access token for the Jenkins user into Secret
    • Give a description and click Add
  • Perform the various API tests to ensure proper connectivity
  • Change the connection description from "Anonymous connection" to something explicit such as "FooBar, Inc. GitHub Enterprise"
  1. Save the Jenkins configuration

Setting up a job/build

  1. Select New Item.
  2. Choose a type (free-style, maven, etc.)
  3. Give it a name.
  4. Complete GitHub project with repository URL. 5 Select Git from Source Code Management options.
  • Complete Repository URL.
  • Under Credentials, click
    • Enter the username for the Jenkins user
    • Enter the Jenkins personal access token as the password
      We don't use the password in case Two Factor Authentication is enabled
    • Click Advanced
      • Under Refspec, enter +refs/pull/*:refs/remotes/origin/pr/*
        This tells the job to only build pull requests
  • Under Branches to build, enter ${sha1}
  1. In the Build Triggers section, select:
  • GitHub Pull Request Builder:
    • Enable User github hooks for build triggering.
    • Click Advanced
    • Select Build every pull request automatically without asking (Dangerous!).
      Don't worry! It's not really dangerous
  1. Add your build steps, then save the job.
  2. This job will now automatically build for each new commit HEAD pushed to a pull request.

Other Jenkins resources

Plugins relating to GitHub/Jenkins integration:

⚠️ **GitHub.com Fallback** ⚠️