{"id":1106,"date":"2024-08-20T14:07:17","date_gmt":"2024-08-20T14:07:17","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=1106"},"modified":"2024-08-20T14:07:17","modified_gmt":"2024-08-20T14:07:17","slug":"enable-jenkins-status-checks-github","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=1106","title":{"rendered":"How to Create GitHub App For Jenkins Status Checks"},"content":{"rendered":"<p>When you use <a href=\"https:\/\/devopscube.com\/jenkins-multibranch-pipeline-tutorial\/\">Jenkins multi-branch pipelines<\/a>, you can integrate status checks with GitHub Pull Requests.<\/p>\n<p>Here is an example of status checks.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-30-13.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>To implement these types of status checks, you need to create a GitHub App that integrates with the Jenkins controller instance.<\/p>\n<p>In this blog, we will look at how to create a GitHub app for enabling status checks in the pipeline.<\/p>\n<h2 id=\"creating-github-app\">Creating Github App<\/h2>\n<p>To create a GitHub App, select your GitHub profile and go to <strong>Settings<\/strong> as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-12-17.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Scroll down and select the <strong>Developer settings<\/strong><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-13-18.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Then click the <strong>New GitHub App<\/strong> button to create a new GitHub app<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-14-26.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>You need to fill out the following details in the configurations.<\/p>\n<ol>\n<li><strong>GitHub App name:<\/strong> This name has to be unique. For example, jenkins-techiescamp-app. Replace it with the required name.<\/li>\n<li><strong>Homepage URL:<\/strong> Enter your Jenkins URL.<\/li>\n<li><strong>Webhook URL:<\/strong> Jenkins URLs with the webhook path (http:\/\/64.227.177.136:30000\/github-webhook\/)<\/li>\n<\/ol>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-15-16.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Under <strong>Repository permissions<\/strong>, choose the following permissions from the drop-down menu.<\/p>\n<ol>\n<li><strong>Administration:<\/strong> Read-only<\/li>\n<li><strong>Checks:<\/strong> Read &amp; write<\/li>\n<li><strong>Commit statuses<\/strong>: Read &amp; write<\/li>\n<li><strong>Contents:<\/strong> Read-only (to read the <code>Jenkinsfile<\/code> and the repository content during <code>git fetch<\/code>).<\/li>\n<li><strong>Metadata:<\/strong> Read-only<\/li>\n<li><strong>Pull requests:<\/strong> Read-only<\/li>\n<\/ol>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-16-20.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Under <strong>Subscribe to events<\/strong>, select the following events:<\/p>\n<ol>\n<li>Check run<\/li>\n<li>Check suite<\/li>\n<li>Pull request<\/li>\n<li>Push<\/li>\n<li>Repository<\/li>\n<\/ol>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-17-16.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Now, click the <strong>Create Github app<\/strong> button.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-18-22.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>After creating the app, you will see a notification to generate the private key as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-19-15.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Click on the <strong>generate the private key<\/strong> option and click <strong>Generate a private key<\/strong> button as given below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-20-19.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>It will download a private key.<\/p>\n<p>Now, you need to convert the key to a format that can be used with Jenkins using the following command. Replace<strong><code> key-in-your-downloads-folder.pem<\/code><\/strong> with your downloaded private key.<\/p>\n<pre><code>openssl pkcs8 -topk8 -inform PEM -outform PEM -in key-in-your-downloads-folder.pem -out converted-github-app.pem -nocrypt<\/code><\/pre>\n<p>We need to add the converted key to Jenkins credentials.<\/p>\n<h2 id=\"install-github-app\">Install Github App<\/h2>\n<p>Now, on the app configuration page, you will see an option called <strong>Install app<\/strong>, as given below. Click that option to enable this app for all the repositories.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-21-14.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Click <strong>Install<\/strong><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-22-16.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>You can choose all or individual repositories you need and then click Install.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-23-15.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<h2 id=\"add-private-key-to-jenkins-credentials\">Add Private Key to Jenkins Credentials<\/h2>\n<p>Now, we need to add the converted PEM key to the Jenkins credentials.<\/p>\n<p>Go to <strong>Jenkins Home &#8211;&gt; manage jenkins &#8211;&gt; Credentials<\/strong>.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-24-14.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Under credentials, select the <strong>global<\/strong> option<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-26-14.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p><!--kg-card-begin: html--><span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">Then, choose the&nbsp;<strong>Add Credentials<\/strong>&nbsp;Option to add a new credential<\/span><!--kg-card-end: html--><\/p>\n<p>.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-27-15.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>Now you need to choose the Kind as GitHub App.<\/p>\n<p>Also we need the <strong>Github App ID<\/strong>. You can get it from the Github App configuration as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-28-12.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>In the key field, add the <strong>converted-github-app.pem<\/strong> private file contents we converted before, and then click the <strong>Create<\/strong> button as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-29-16.png\" class=\"kg-image\" alt loading=\"lazy\"><\/figure>\n<p>That&#8217;s pretty much it.<\/p>\n<p>Now, you can use this credential in the multi-branch pipeline to enable checks during PR.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/enable-jenkins-status-checks-github\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Create GitHub App For Jenkins Status Checks \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/enable-jenkins-status-checks-github\/<\/p>\n","protected":false},"author":1,"featured_media":1107,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1106"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/1106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/1107"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}