pagure_ci.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. =========
  2. Pagure CI
  3. =========
  4. Pagure CI is a continuous integration tool using which the PR on the projects
  5. can be tested and flaged with the status of the build.
  6. How to enable Pagure CI
  7. =======================
  8. * Enable the Fedmsg plugin in pagure project setting . This will emit the message
  9. to for consumer to consume it.
  10. * Fill in the Pagure CI form with the required details.
  11. ::
  12. Pagure Project Name
  13. Jenkins Project Name
  14. Jenkins Token
  15. Jenkins Url
  16. All of which are required field.
  17. * The jenkins token is any string that you give here. The only thing that should
  18. be kept in mind that this token should be same through out.
  19. * This will give a POST URL which will be used for Job Notification in Jenkins
  20. * The POST url will only appear only after you successfully submitted the form.
  21. Configuring Jenkins
  22. ===================
  23. Jenkins configuration is the most important part of how the Pagure CI works,
  24. after you login to your Jenkins Instance.
  25. * Go to Manage Jenkins -> Configuire Global Security and under that select
  26. `Project-based Matrix Authorization Strategy`
  27. * Add your username here and make sure to give that username all the permissions.
  28. You should give all the permissions possible so that you save your self from
  29. getting locked in Jenkins.
  30. * Download the following plugins:
  31. ::
  32. Build Authorization Root Plugin
  33. Git Plugins
  34. Notification Plugin
  35. * Click on the New Item
  36. * Select Freestyle Project
  37. * Click OK and enter the name of the project, make sure the project name
  38. you filled in the Pagure CI form should match the name you entered here.
  39. * Under 'Job Notification' click 'Add Endpoint'
  40. * Fields in Endpoint will be :
  41. ::
  42. FORMAT: JSON
  43. PROTOCOL: HTTP
  44. EVENT: Job Finalized
  45. URL: <The POST URL that Jenkins form returned>
  46. TIMEOUT: 3000
  47. LOG: 1
  48. * Tick the build is parameterized
  49. * From the Add Parameter drop down select String Parameter
  50. * Two string parameters need to be created REPO and BRANCH
  51. * Source Code Management select Git and give the URL of the pagure project
  52. * Under Build Trigger click on Trigger build remotely and give the same token
  53. that you gave in the Pagure CI form.
  54. * Under Build -> Add build step -> Execute Shell
  55. * In the box given enter the shell steps you want for testing your project.
  56. Example Script
  57. ::
  58. if [ -n "$REPO" -a -n "$BRANCH" ]; then
  59. git remote rm proposed || true
  60. git remote add proposed "$REPO"
  61. git fetch proposed
  62. git checkout origin/master
  63. git config --global user.email "you@example.com"
  64. git config --global user.name "Your Name"
  65. git merge --no-ff "proposed/$BRANCH" -m "Merge PR"
  66. fi
  67. How to install Pagure CI
  68. ========================
  69. Pagure CI requires `fedmsg` to run since it uses a consumer to get messages
  70. and take appropriate actions. The dependency that is required is `fedmdg-hubs`.
  71. For that the steps are given.
  72. To install the dependencies required:
  73. `dnf install fedmsg-hub`
  74. `fedmsg` apart from the consumer require a file that tells to which cosumer
  75. it should listen to. This file basically enable the consumer in PagureCI/.
  76. For doing that, we need to place this file in appropriate directory.
  77. `sudo cp pagure/fedmsg.d/pagure_ci.py /etc/fedmsg.d/`
  78. Since the deployment is done using rpm, the next step is covered using `setup.py`
  79. which binds the consumer with the environment, this is done while building the rpm
  80. so if rpm is already built this is not explicitly required.
  81. `python setup.py install`
  82. Run the service:
  83. `sudo systemctl enable fedmsg-hub.service`
  84. `sudo systemctl start fedmsg-hub.service`