Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

This page explains how to integrate Jenkins builds into a GitHub workflow. In particular:

  • a Jenkins build gets triggered by any PR or any update to any PR

  • the outcome of the Jenkins build outcome is displayed on GitHub

  • a Jenkins build failure disables the GitHub merge button

Instructions

start:

  • an existing repo

  • a Jenkins machine

end:

  • one more job on Jenkins

  • GitHub repo linked

Create Job on Jenkins

  1. install plugin

    1. Log into builder.openwsn.org

    2. Go to Manage Jenkins → Manage Plugins , under Available tab, search for ”GitHub pull request builder”

    3. Mark the checkbox and click Install without restart to install

    4. Go to builder.openwsn.org/restart and click Yes to restart Jenkins

  2. Configure plugin

    1. Go to Manage Jenkins → Configure System, in GitHub Pull Request Builder setting, add the GitHub account into the credentials area. The GitHub account needs to have admin rights on the repository (pull/push is NOT enough).

    2. Click Test Credentials... button, verify you read Test basic connection to GitHub

    3. Click Connect to API button, verify you read “Connected to https://api.github.com…”

    4. Check Auto-manage webhooks checkbox

    5. in the “admin list“, add the GitHub account

    6. Leave the rest as default and click Save to save the settings

  3. create new job

    1. Click New Item to create a job, give a name of the job, select Freestyle project and then click OK to get in the job configure page

    2. In the General Tab, check GitHub project and put the repository url there, e.g. “https://github.com/changtengfei/dummy_test

    3. In the Source Code Management Tab, select Git, put the same URL and leave the credentials as “none”

    4. Click the Advanced… button and put “+refs/pull/:refs/remotes/origin/pr/” in the Refspec field. This tells the Jenkins job, when it runs, to retrieve the list of branches from the forked repo.

    5. In the branches to build section, enter “${sha1}” in the branch Specifier textfield. This tells Jenkins to merge in the branch specified in the PR.

    6. In the Build Triggers Tab

      1. check GitHub Pull Request Builder

      2. put the GitHub admin account in the Admin list field

      3. check the use GitHub hooks for build triggering

      4. check the Build every pull request automatically without asking (Dangerous!)

      5. leave the rest settings as default.

    7. In the Build Tab

      1. put the test script you want the job to do after getting the code from the Pull Request.

    8. In Post-build Actions, add any post actions you want after the build process is done.

    9. Click Save to save the settings.

Create webhook on GitHub

  1.  Log into your GitHub account, that must be an account with admin privileges to the repo

  2. In the Settings tab of the repo, click on Webhooks

  3. Click Add webhook, under Webhooks / Manage webhook

    1. Put <https://openwsn-builder.paris.inria.fr/ghprbhook/> (“ghprbhook“ is a magic string identifying the GitHub PR build book plug) in the Payload URL

    2. Select Let me select individual events and check the Pull Request and Push as the event to trigger the build

    3. Click Update webhook to create the webhook

  4. You should see the payload URL is the Webhooks list, with a green check mark.

Demo

Related

ADM-2 - Getting issue details... STATUS

  • No labels