pagure_ci_jenkins.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Jenkins with Pagure-ci
  2. ======================
  3. Jenkins is a Continuous Integration service that can be configured to be
  4. integrated with pagure.
  5. This document describe the steps needed to make it work.
  6. How to enable Pagure CI
  7. -----------------------
  8. * Visit the settings page of your project
  9. * Scroll down to the `Hooks` section and click on `Pagure CI`
  10. * Select the type of CI service you want
  11. * Enter the URL of the CI service. For example `http://jenkins.fedoraproject.org`
  12. * Enter the name of the job the CI service will trigger. For example `pagure-ci`
  13. * Tick the checkbox activating the hook. Either trigger on every commits, trigger only
  14. on pull-requests or both every commits and pull-requests.
  15. These steps will activate the hook, after reloading the page or the tab, you
  16. will be given access to two important values: the token used to trigger the
  17. build on jenkins and the URL used by jenkins to report the status of the
  18. build.
  19. Keep these two available when configuring jenkins for your project.
  20. Configure Jenkins
  21. -----------------
  22. These steps can only be made by the admins of your jenkins instance, but
  23. they only need to be made once.
  24. * Download the following plugins:
  25. * `Git Plugin <https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin>`_
  26. * `Notification Plugin <https://wiki.jenkins-ci.org/display/JENKINS/Notification+Plugin>`_
  27. Configure your project on Jenkins
  28. ---------------------------------
  29. * Go to the `Configure` page of your project
  30. * Under `Job Notification` click `Add Endpoint`
  31. * Fields in Endpoint will be :
  32. ::
  33. FORMAT: JSON
  34. PROTOCOL: HTTP
  35. EVENT: All Events
  36. URL: <The URL provided in the Pagure CI hook on pagure>
  37. TIMEOUT: 3000
  38. LOG: 1
  39. * Tick the checkbox `This build is parameterized`
  40. * Add two `String Parameters` named REPO and BRANCH
  41. * Source Code Management select Git and give the URL of the pagure project
  42. * Under Build Trigger click on Trigger build remotely and specify the token
  43. given by pagure.
  44. * Under Build -> Add build step -> Execute Shell
  45. * In the box given enter the shell steps you want for testing your project.
  46. Example Script
  47. ::
  48. # Script specific for Pull-Request build
  49. if [ -n "$REPO" -a -n "$BRANCH" ]; then
  50. git remote rm proposed || true
  51. git remote add proposed "$REPO"
  52. git fetch proposed
  53. git checkout origin/master
  54. git config --global user.email "you@example.com"
  55. git config --global user.name "Your Name"
  56. git merge --no-ff "proposed/$BRANCH" -m "Merge PR"
  57. fi
  58. # Part of the script specific to how you run the tests on your project