jenkins - aetas-github-training/Support GitHub Wiki
- Ensure that the GitHub Enterprise instance can access the Jenkins instance by URL or IP
- Create a user in GitHub Enterprise that will be dedicated to operating as Jenkins or leverage an existing user.
- Create a personal access token for this user with
repo
and repo:status
scopes
- Grant the Jenkins user
admin
access to applicable repositories using teams
- Select Manage Jenkins menu.
- Click Manage Plugins.
- Install the GitHub plugin and the GitHub Pull Request Builder. This will cause the GitHub API Plugin to be installed as a dependency.
- Ensure all three plugins are enabled and that Jenkins has restarted.
- Select Manage Jenkins menu.
- Select Configure System link.
- 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"
- Save the Jenkins configuration
- Select New Item.
- Choose a type (free-style, maven, etc.)
- Give it a name.
- 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}
- 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
- Add your build steps, then save the job.
- This job will now automatically build for each new commit HEAD pushed to a pull request.
Plugins relating to GitHub/Jenkins integration:
⚠️ **GitHub.com Fallback** ⚠️