[FrontPage] [TitleIndex] [WordIndex

This is a read-only archived version of wiki.centos.org

Integrating Jobs on ci.centos.org with Github

We use the Github Pull Request Builder and Github plugins for handling the communication between Jenkins and Github Pull requests.

There are 2 basic workflows for triggering builds based on activity on Github:

1. Repo Setup

These steps are common no matter which mode you choose

When configuring a new job:

  1. Open the job config and select 'Github Project' under the General tab. Paste in the frontpage of your github repository.

    For example, the CentOS t_functional test suite has a frontpage of https://github.com/CentOS/sig-core-t_functional

  2. Add your full git url under Source Code Management section

    Continuing with the same example, you would use: https://github.com/CentOS/sig-core-t_functional.git

  3. Choose your trigger strategy (See Mode 1 or Mode 2 below)

If you're using Jenkins Job Builder to configure your jenkins jobs, here is a useful link to know how to do that : https://docs.openstack.org/infra/jenkins-job-builder/triggers.html?highlight=github#triggers.github-pull-request

2. Mode 1: Trigger on Every Commit

This mode simply triggers Jenkins jobs after someone has pushed to master (or another branch) on your Github repository.

After completing the Repo Setup steps:

  1. In the 'Build Triggers' section, select 'Build when a change is pushed to GitHub'

  2. Add a Webhook to your repository pointing at https://ci.centos.org/github-webhook/

    1. On your Github Project page, choose 'Settings'
    2. Navigate to the 'Webhooks and Services' tab
    3. Choose 'Add a webhook'
    4. Paste 'https://ci.centos.org/github-webhook/' in the Payload URL

    5. Open the new webhook and verify the ping in the Recent Deliveries section

3. Mode 2: Trigger a build for each Pull Request

This mode requires a bit more setup, but can trigger on and report the status of a Jenkins job on each pull request

After completing the Repo Setup steps:

  1. On Github, add the 'centos-ci' user as a collaborator on your repository

    /!\ This gives ci.centos.org commit access in order to set the test status on each pull request

    1. In your repository visit the Collaborators tab in the repo Settings
    2. Search by username 'centos-ci' and click 'Add Collaborator'
  2. Add the Github Pull Request Builder webhook
    1. On your Github Project page, choose 'Settings'
    2. Navigate to the 'Webhooks and Services' tab
    3. Choose 'Add a webhook'
    4. Select 'Let me select individual events' under 'Which events would you like to trigger this webhook?'
    5. Unselect 'Push' and select 'Pull Request' and 'Issue Comment'
    6. Paste 'https://ci.centos.org/ghprbhook/' (note the trailing slash) in the Payload URL

    7. Open the new webhook and verify the ping the Recent Deliveries section
  3. In the 'Build Triggers' section, Select 'GitHub Pull Request Builder'

  4. Add the github usernames of your team in the 'Admin List'
    • Pull requests coming from Github users in the Admin List or the whitelist will automatically be tested in ci.c.o
    • Pull requests coming from other users will need to be triggered in a comment on the PR using the trigger phrase (ex: 'dotests') by someone in the Admin list
  5. To pull the correct source code for each pull request we need to modify the SCM Section of the Jenkins job config
    1. Under 'Source Code Management' click 'Advanced' under the repository you added before
    2. Add +refs/pull/*:refs/remotes/origin/pr/* for the refspec attribute

    3. Under the 'Branches to Build' section add  ${ghprbActualCommit} 


2023-09-11 07:23