-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
GitHub app blog #2988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
GitHub app blog #2988
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
57ec687
GitHub app blog
timja cf0df6c
Apply suggestions from code review
timja 49361b7
Apply suggestions from code review
timja fd6d8be
Update content/blog/2020/03/2020-03-19-github-app-authentication.adoc
timja b3318d5
Update content/blog/2020/03/2020-03-19-github-app-authentication.adoc
timja bd33c15
Update content/blog/2020/03/2020-03-19-github-app-authentication.adoc
timja c1a01dc
Merge branch 'master' into github-app
timja 50e435d
Merge branch 'github-app' of github.com:timja/jenkins.io into github-app
timja 4bf840d
Update content/blog/2020/03/2020-03-19-github-app-authentication.adoc
timja e15f4d8
Update content/blog/2020/03/2020-03-19-github-app-authentication.adoc
timja 998bc9b
Apply suggestions from code review
timja b6c988f
Merge branch 'master' into github-app
timja 5ddb9dd
Add more examples and mention token is valid for 1hr
timja a42e4df
Apply suggestions from code review
timja d6284fb
Update content/blog/2020/04/2020-04-16-github-app-authentication.adoc
timja 34325ef
Add social media image
timja 1e7c216
rendering tweaks
timja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
content/blog/2020/03/2020-03-19-github-app-authentication.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| layout: post | ||
| title: "GitHub app authentication released" | ||
| tags: | ||
| - github | ||
| - github-branch-source | ||
| author: timja | ||
| --- | ||
|
|
||
| I'm excited to announce support for authenticating as a GitHub app in Jenkins. | ||
|
||
|
|
||
| It has been released in link:https://github.com/jenkinsci/github-branch-source-plugin/releases/tag/github-branch-source-2.7.0[GitHub Branch Source 2.7.0] | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| This has been a long awaited feature by many users, | ||
|
|
||
| It brings many benefits: | ||
|
|
||
| * the rate limit for a GitHub app scales with your organization size, | ||
| whereas a user based token has a limit of 5000 regardless of how many repositories you have, | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * for organizations that have 2FA enforced - no need to manage 2FA tokens for a 'bot' user | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * to improve and tighten security: the Jenkins GitHub app requires a minimum, controlled set of privileges compared to a service user and its personal access token which has a much wider set of privileges | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| == Getting started | ||
|
|
||
| Install the link:https://plugins.jenkins.io/github-branch-source/[GitHub Branch Source plugin], | ||
| make sure the version is at least 2.7.0. | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Follow the link:https://github.com/jenkinsci/github-branch-source-plugin/blob/master/docs/github-app.adoc[setup guide]; it's also linked to from the plugin’s README on GitHub. | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Once you've finished setting it up, Jenkins will validate your credential and you should see your new rate limit. | ||
| Here's an example on a large org: | ||
|
|
||
| image:/images/github-app-rate-limit.png[GitHub app rate limit] | ||
|
|
||
| == How do I get an API token in my pipeline? | ||
|
|
||
| You can access the Bearer token for the GitHub API by just loading a 'Username/Password' credential as usual, | ||
| the plugin will handle authenticating with GitHub in the background: | ||
|
|
||
| [source, groovy] | ||
| ---- | ||
| pipeline { | ||
| agent any | ||
| stages{ | ||
| stage('Check run') { | ||
| steps { | ||
| withCredentials([usernamePassword(credentialsId: 'githubapp-jenkins', usernameVariable: 'GITHUB_APP', passwordVariable: 'GITHUB_JWT_TOKEN')]) { | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sh ''' | ||
| curl -H "Content-Type: application/json" -H "Accept: application/vnd.github.antiope-preview+json" -H "authorization: Bearer ${GITHUB_JWT_TOKEN}" -d '{ "name": "check_run", "head_sha": "'${GIT_COMMIT}'", "status": "in_progress", "external_id": "42", "started_at": "2020-03-05T11:14:52Z", "output": { "title": "Check run from Jenkins!", "summary": "This is a check run which has been generated from Jenkins as GitHub App", "text": "...and that is awesome"}}' https://api.github.com/repos/<org>/<repo>/check-runs | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ''' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ---- | ||
|
|
||
| == What's next | ||
|
|
||
| There's a proposed Google Summer of Code project: link:https://jenkins.io/projects/gsoc/2020/project-ideas/github-checks/[GitHub Checks API for Jenkins Plugins]. | ||
|
|
||
| This is looking at integrating with the link:https://developer.github.com/v3/checks/[checks api], with a focus on reporting issues found using the link:https://plugins.jenkins.io/warnings-ng/[warnings-ng plugin] directly onto the GitHub pull request, along with test results summary on GitHub. | ||
|
|
||
| If you want to get involved with this join the link:https://gitter.im/jenkinsci/gsoc-sig[gitter channel] and ask how you can help, there's already students sending in their proposals. | ||
timja marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.