`

如何用Jenkins/Hudson自动构建OpenELEC

 
阅读更多

 

 

http://openelec.tv/forum/20-development-discussion/16247-how-to-build-openelec-using-hudsonjenkins-ci-continuous-integration-server#36754

 

Here are the steps that I took to get Hudson/Jenkins (I moved to Jenkins as it is updated more frequently) up and running in n Ubuntu 11.04 x64 Hyper-V VM. This tutorial assumes you already know how to set up Ubuntu to build openelec...if not, search on here for a guide on what you need. This guide should also work on VMware Virtual Machines, but I'm using Hyper V.


1.)Install Ubuntu Server Choosing Tomcat, SSH, and optionally Samba (if you want to pull files from windows). After you have Ubuntu installed, follow the directions here on how to get Ubuntu set up for hyper-v.

1a.) Configure Ubuntu for building. you can use the following command:

sudo apt-get  install build-essential g++ nasm flex bison gawk gperf autoconf automake m4 cvs libtool byacc texinfo gettext zlib1g-dev libncurses5-dev zip unzip xsltproc



2.)Install Hudson:

sudo sh -c "echo 'deb http://hudson-ci.org/debian binary/' > /etc/apt/sources.list.d/hudson.list"
sudo apt-get update
sudo apt-get install hudson


3.) You may need to change the default port Hudson listens on, which is 80. I chose 9090

sudo perl -pi -e 's/HTTP_PORT=(.*)\n/HTTP_PORT=9090\n/g' /etc/default/hudson


3a.) If you change the port, restart hudson by typing:

service hudson restart


4.) Check if Hudson works. In a browser, open "XXX.XXX.XXX.XXX:YYYY" where XXX... is your IP address, and YYYY is the Port you used. If all goes well, you should see something like the following (minus the jobs):


5.) Now that Hudson is installed, you'll need to add the Git plugin, if not already installed. To do this, go to "Manage Hudson" -> "Manage Plugins" -> Click "Available", and look for the "Git" SCM plugin. Once you install the plugin, you'll need to have Hudson restart, so click the box at the bottom. Once it restarts, you can continue.

6.) Configure the Git username/email: Click "Manage Hudson" and look for the GIT data, enter your username and email address so git can know who you are:


7.) Configure a project

  • a.) Select New project
  • b.) Enter a name for the project (Note, cannot contain spaces...OpenELEC will not build)
  • c.) Make sure you select "Build a free-style software project" and then click "OK"
  • d.) Enter the following information, in the correct boxes

 

  1. Github Project: github.com/OpenELEC/OpenELEC.tv/
  2. Source Code Management: Click Git, enter "github.com/OpenELEC/OpenELEC.tv.git" for Repository, then
  3. click advanced, and make sure you have the following:
  4. branches to build: master
  5. Under "Build" click "add build step" and select "execute Shell"
  6. Note: you'll need to make a shell script and put it somewhere, like your /home/user directory. For a simple build script, you can use something like the following:
  7.   #!/bin/sh
      PROJECT=ION ARCH=x86_64 make release
      
    Or.... you can do something much more complicated, like my original scripts did (log time it took, mail, and ftp the results, then delete all records of the build folder:
    #!/bin/sh
    date1=$(date +%s)
    PROJECT=ION ARCH=x86_64 make release
    date2=$(date +%s)
    date3=$(date)
    if [ -s target/OpenELEC-ION.x86_64*.bz2 ]; then
    echo 'Date/Time build finished:' $date3  > /home/evan/buildstatus.txt
    echo 'Date/Time finished: ' $date3 >> /home/evan/buildlog.txt
    echo 'Time for ION x64 build:' $((($date2-$date1)/(60))) minutes, $((($date2-$date1) % 60)) seconds >> /home/evan/buildlog.txt
    echo 'Time for ION x64 build:' $((($date2-$date1)/(60))) minutes, $((($date2-$date1) % 60)) seconds >> /home/evan/buildstatus.txt
    FILESIZE=$(stat --printf="%s" target/OpenELEC-ION.x86_64*.bz2)
    echo 'Total File Size: ' $FILESIZE bytes >> /home/evan/buildstatus.txt
    ncftpput -u username -p password myftp.com /ION target/OpenELEC-ION.x86_64*.bz2
    FNAME=$(stat --printf="%n" target/OpenELEC-ION.x86_64*.bz2)
    REV=$(echo $FNAME | awk '{print substr($0, length($0) - 12,5)}')
    #mailx  -s "OpenELEC.tv ION x64 Build $REV complete" email@server.com < /home/evan/buildstatus.txt
    rm -f target/OpenELEC-ION.x86_64*.*
    rm -rf build.OpenELEC-ION.x86_64-devel
    
  8. call it something like "buildion64.sh" or whatever, give it +x permissions by chmoding +x, and remember where you saved it. In the screenshot above, you can see I entered it already, you'll have to enter yours just like I did, where it says "sh /home/<user>/blah.sh"



That's pretty much all you need to get it up and running. Once you save your Job, you can create new ones. If you install the "template" plugin, you can use previously created jobs to fast-make new ones. Make sure you setup a .sh script to build each project you want. One major note. This by default will create separate folders for EACH build you make, so if you go and build 6 different versions (like I do) it's going to clone the git project 6 times. That will take up a lot of disk space, so you may want to go in to your advanced project properties (click the button) and set the workspace to be the same, such as mine:

/var/lib/jenkins/jobs/OpenELEC.tv/workspace/




Note #2: When you build for the first time, it won't give you an ETA. Once you successfully build however, it should be able to try and predict how long new builds will take (uses the last build time.) If you'd rather use Jenkins, you can Google how to switch from Hudson to Jenkins, it takes about 2 seconds to do and you don't loose any of your jobs.

Note #3: Per "MikeBuzz", you may need to do the following as well. I did not, but he did on his system if you get errors with git when pulling for the first time:

sudo -s -H -u hudson
git config --global user.name "Hudson"
git config --global user.email "hudson@mydomain.com"
exit



if using jenkins

sudo -s -H -u jenkins
git config --global user.name "Hudson"
git config --global user.email "hudson@mydomain.com"
exit



Thanks Mike!


Please let me know if you have any questions. Mods, can we move this to the "Guides" section please?

HTPC: Zotac ION-A-U with 4GB ram & 32GB SSD
Build box/File Server: W2k8 R2, AMD x3 455, 14TB RAID 5 with 2TB Samsung HD204UI drives.

Too lazy to roll your own builds? take mine: http://www.mediafire.com/openelec
Want to check my build status? check here:EvanRich's Jenkins CI server
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics