Custom Search

Monday, March 31, 2014

How to Jenkins Create a Debian Package for OpenStack python-heatclient

1)
Install Jenkins and Plugins
http://fosshelp.blogspot.in/2014/04/install-jenkins-and-github-plugin.html

2)
Get debian packaging script for python-heatclient project.
#sudo apt-get install devscripts

Goto following link and locate your project's *.dsc file
http://ubuntu-cloud.archive.canonical.com/ubuntu/pool/main/

Download the packaging script and extract it
#dget http://ubuntu-cloud.archive.canonical.com/ubuntu/pool/main/p/python-heatclient/python-heatclient_0.2.8-0ubuntu1~cloud0.dsc
#tar -xzf python-heatclient_0.2.8-0ubuntu1~cloud0.debian.tar.gz
#cd debian
#ls




3)
Clone the source code of python-heatclient
#git clone https://github.com/sajuptpm/python-heatclient.git
#cd python-heatclient


Create a new branch named "packaging" if not exist and switch to that branch.
#git checkout -b packaging

4)
Copy debian folder (packaging script) to "packaging" branch
#cp -r ../../debian .
#git status
#git add debian
#git commit debian
#git status


5)
Push packaging branch to remote to remote github repo
#git remote -v
#git push origin packaging


6)
Create build job in Jenkins

a)
Goto "New Item" --> type name for the new job/item --> Select "Build a free-style software project"

b)
* Under "Source Code Management" ---> Select "Git" ---> Type Repository URL (eg:https://github.com/sajuptpm/python-heatclient.git)

* Credentials --> Click on "Add" button --> Select kind "username and password" --> Give your github username and password -> Click "Add"

* Branches to build --> Type "origin/master" or "*/master"

c)
Under "Additional Behaviours" Section:
* Check out to a sub-directory --> Local subdirectory for repo : "build"

* Strategy for choosing what to build -->     Choosing strategy    --> "default"

d)
Under "Build Triggers" Section:
* Select "Build when a change is pushed to GitHub"

e)
Add following script Under "Build" Section:
* Excecute Shell --> Command
-----------------------
#!/bin/bash -xe
rm -f *.deb
cd build
if ! git checkout packaging
then
    git checkout -b packaging origin/packaging
fi
git checkout packaging
dpkg-buildpackage -b
git push origin packaging || true


f)
Under "Post-build Actions" Section:
* Archive the artifacts --> Files to archive --> "*.deb"

g)
Save

7)
Build the package

a) 
Job Workspace:
* if you need to try build with fresh copy of repo, delete the workspace and run build again.
* In workspace you can see the cloned repo, build directory and debian package
* You can also download the workspace as a zip file
http://192.168.56.101:8080/job/test1/ws/

b)
Configure the job:
http://192.168.56.101:8080/job/test1/configure

c)
Console log of build Job:
http://192.168.56.101:8080/job/test1/28/console

* Explain each line of console log when build get succeeded
Example Log:
Started by user anonymous

#Create workspace directory
Building in workspace /var/lib/jenkins/jobs/test1/workspace

#Clone the repo
Fetching changes from the remote Git repository
Fetching upstream changes from https://github.com/sajuptpm/python-heatclient.git
using .gitcredentials to set credentials
Checking out Revision 03f5d54b1fefb70850b2c0882fdb561a199a9b85 (origin/master)

#Goto workspace directory /var/lib/jenkins/jobs/test1/workspace and execute build script.
[workspace] $ /bin/bash -xe /tmp/hudson2998818138453737595.sh
+ rm -f '*.deb'
+ cd build
+ git checkout packaging
+ dpkg-buildpackage -b

8)
Dependencies of dpkg-buildpackage command

#sudo apt-get install dpkg-dev
#sudo apt-get install debhelper
#sudo apt-get install python-all


* http://ftp.br.debian.org/debian/pool/main/p/python-mox3/python-mox3_0.7.0-1_all.deb
#sudo gdebi python-mox3_0.7.0-1_all.deb 


9)
Packaging Script:
https://github.com/sajuptpm/python-heatclient-debian-packaging



No comments:

Post a Comment