Blame doc/pagure_ci.rst

farhaanbukhsh 3f88c9
=========
farhaanbukhsh 3f88c9
Pagure CI
farhaanbukhsh 3f88c9
=========
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
Pagure CI is a continuous integration tool using which the PR on the projects
farhaanbukhsh 52f61f
can be tested and flaged with the status of the build.
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
How to enable Pagure CI
farhaanbukhsh 3f88c9
=======================
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
* Enable the Fedmsg plugin in pagure project setting . This will emit the message
farhaanbukhsh 52f61f
  to for consumer to consume it.
farhaanbukhsh 52f61f
farhaanbukhsh 3f88c9
* Fill in the Pagure CI form with the required details. 
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
::
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
		Pagure Project Name
farhaanbukhsh 3f88c9
		Jenkins Project Name
farhaanbukhsh 3f88c9
		Jenkins Token
farhaanbukhsh 3f88c9
		Jenkins Url
farhaanbukhsh 3f88c9
	
farhaanbukhsh 3f88c9
        All of which are required field.
farhaanbukhsh 3f88c9
Farhaan Bukhsh c5c8d4
* The jenkins token is any string that you give here. The only thing that should
Farhaan Bukhsh c5c8d4
  be kept in mind that this token should be same through out.
farhaanbukhsh 3f88c9
		
farhaanbukhsh 3f88c9
* This will give a POST URL which will be used for Job Notification in Jenkins
farhaanbukhsh 3f88c9
Farhaan Bukhsh c5c8d4
* The POST url will only appear only after you successfully submitted the form.
Farhaan Bukhsh c5c8d4
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
Configuring Jenkins
farhaanbukhsh 3f88c9
===================
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
Jenkins configuration is the most important part of how the Pagure CI works,
farhaanbukhsh 52f61f
after you login to your Jenkins Instance.
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
* Go to Manage Jenkins -> Configuire Global Security and under that select
farhaanbukhsh 52f61f
  `Project-based Matrix Authorization Strategy`
farhaanbukhsh 3f88c9
Farhaan Bukhsh c5c8d4
* Add your username here and make sure to give that username all the permissions.
Farhaan Bukhsh c5c8d4
  You should give all the permissions possible so that you save your self from
Farhaan Bukhsh c5c8d4
  getting locked in Jenkins.
Farhaan Bukhsh c5c8d4
farhaanbukhsh 3f88c9
* Download the following plugins:
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
::
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
      Build Authorization Root Plugin
farhaanbukhsh 3f88c9
      Git Plugins
farhaanbukhsh 3f88c9
      Notification Plugin
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Click on the New Item
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Select Freestyle Project
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
* Click OK and enter the name of the project, make sure the project name
farhaanbukhsh 52f61f
  you filled in the Pagure CI form should match the name you entered here.
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Under 'Job Notification'  click 'Add Endpoint'
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Fields in Endpoint will be :
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
::
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
		FORMAT: JSON
farhaanbukhsh 3f88c9
		PROTOCOL: HTTP
Farhaan Bukhsh c5c8d4
		EVENT: Job Finalized
farhaanbukhsh 3f88c9
		URL: <the form="" jenkins="" post="" returned="" that="" url=""></the>
farhaanbukhsh 3f88c9
		TIMEOUT: 3000
farhaanbukhsh 3f88c9
		LOG: 1
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Tick the build is parameterized
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* From the Add Parameter drop down select String Parameter
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Two string parameters need to be created REPO and BRANCH
farhaanbukhsh 3f88c9
Farhaan Bukhsh c5c8d4
* Source Code Management select Git and give the URL of the pagure project
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
* Under Build Trigger click on Trigger build remotely and give the same token
farhaanbukhsh 52f61f
  that you gave in the Pagure CI form.
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* Under Build -> Add build step -> Execute Shell
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
* In the box given  enter the shell steps you want for testing your project.
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
Example Script
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
::
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
        if [ -n "$REPO" -a -n "$BRANCH" ]; then
farhaanbukhsh 3f88c9
        git remote rm proposed || true
farhaanbukhsh 3f88c9
        git remote add proposed "$REPO"
farhaanbukhsh 3f88c9
        git fetch proposed
farhaanbukhsh 3f88c9
        git checkout origin/master
farhaanbukhsh 3f88c9
        git config --global user.email "you@example.com"
farhaanbukhsh 3f88c9
        git config --global user.name "Your Name"
farhaanbukhsh 3f88c9
        git merge --no-ff "proposed/$BRANCH" -m "Merge PR"
farhaanbukhsh 3f88c9
        fi
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
How to install Pagure CI
farhaanbukhsh 3f88c9
========================
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
Pagure CI requires `fedmsg` to run since it uses a consumer to get messages
farhaanbukhsh 52f61f
and take appropriate actions. The dependency that is required is `fedmdg-hubs`.
farhaanbukhsh 52f61f
For that the steps are given.
farhaanbukhsh 52f61f
farhaanbukhsh 3f88c9
To install the dependencies required:
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
	 `dnf install fedmsg-hub`
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
`fedmsg` apart from the consumer require a file that tells to which cosumer
farhaanbukhsh 52f61f
it should listen to. This file basically enable the consumer in PagureCI/.
farhaanbukhsh 52f61f
For doing that, we need to place this file in appropriate directory.
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
	 `sudo cp pagure/fedmsg.d/pagure_ci.py /etc/fedmsg.d/`
farhaanbukhsh 3f88c9
farhaanbukhsh 52f61f
Since the deployment is done using rpm, the next step is covered using  `setup.py`
farhaanbukhsh 52f61f
which binds the consumer with the environment, this is done while building the rpm
farhaanbukhsh 52f61f
so if rpm is already built this is not explicitly required.
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
	`python setup.py install`
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
Run the service:
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
    `sudo systemctl enable fedmsg-hub.service`
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
    `sudo systemctl start fedmsg-hub.service`
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9
farhaanbukhsh 3f88c9