Pagure CI With Fedora Jenkins
This is a brief guide on how to enable Pagure CI with Jenkins from Fedora infrastructure.
Request Jenkins instance for your project
This is actually a very simple process, create a ticket on the fedora-infrastructure project on pagure with the following information:
- Subject: [Jenkins] project request: <name of your project>
- Body:
- name of the project
- One line description of the project
- Contact person for this / admin for the project
- URL to the sources of the project
- Remarks
The URL is actually not needed but asked so that infra team can have a quick look at your project and see if (at least) license wise it follows Fedora's philosophy.
Enable Pagure CI for your project
- Visit the settings page of your project
- Scroll down to the Hooks section and click on Pagure CI
- Select the type of CI service you want
- Enter the URL to the project on the CI service. For example, if your project is running at http://jenkins.fedoraproject.org you will need to enter the url: http://jenkins.fedoraproject.org/job/<projectname>
- Tick the checkbox activating the hook.
These steps will activate the hook, after reloading the page or the tab, you will be given access to two important values: the token used to trigger the build on jenkins and the URL used by jenkins to report the status of the build. Keep these two available when configuring jenkins for your project.
Configure your project on Jenkins
- Go to the Configure page of your project
- Under Job Notification click Add Endpoint
- Fields in Endpoint will be :
FORMAT: JSON PROTOCOL: HTTP EVENT: Job Finalized URL: <The URL provided in the Pagure CI hook on pagure> TIMEOUT: 3000 LOG: 1
- Tick the checkbox This build is parameterized
- Add two String Parameters named REPO and BRANCH
- Source Code Management select Git and give the URL of the pagure project
- Under Build Trigger click on Trigger build remotely and specify the token given by pagure.
- Under Build -> Add build step -> Execute Shell
- In the box given enter the shell steps you want for testing your project.
Example Script
# Script specific for Pull-Request build if [ -n "$REPO" -a -n "$BRANCH" ]; then git remote rm proposed || true git remote add proposed "$REPO" git fetch proposed git checkout origin/master git config --global user.email "you@example.com" git config --global user.name "Your Name" git merge --no-ff "proposed/$BRANCH" -m "Merge PR" fi # Part of the script specific to how you run the tests on your project
References: