2011年7月21日 星期四

Jenkins notes

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key

sudo apt-key add -

sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'

sudo aptitude update

sudo aptitude install jenkins





sudo aptitude install apache2

sudo a2enmod proxy

sudo a2enmod proxy_http

sudo a2enmod vhost_alias







************************改Port************************



Change /etc/default/hudson and add this to passed in arguments:

HUDSON_ARGS="--httpPort=8081 --webroot=/var/run/hudson/war"





************************為jenkins加上gitosis的ssh key************************



參考http://shreevatsa.wordpress.com/2005/11/17/ssh-keygen-as-another-user/



主要是在自己的帳戶路徑內,產生一個key pair,然後將.pub這個publish key,cp到你要登入目標的.ssh/authorized_keys裡面。

這等於連去對方的時候,對方的ssh會對照.ssh/authorized_keys是否與你擁有的private key是一對的。



然後就可以登入

sudo ssh -i id_rda_jenkins jenkins@10.1.5.203







************************設定目標專案的sudo免打密碼************************



在最後一行加上,sudo的權限是從上到下,任何最下面的設定都會蓋過上面的

hawk ALL=(ALL) NOPASSWD: ALL





************************設定某個repository被git push後,觸發jenkins************************



在server上bare git repository裡面的hooks 裡面加上一個名為post-update的可執行檔,內容是:

curl http://${JENKINS_SERVER}:${PORT}/job/${PROJECT_NAME}/build?delay=0sec

就會在有人作了push動作以後,執行jenkins裡設定的build script。

Build Script裡面就可以寫個repo sync去同步所有的git。





************************安裝jenkins衝到其他網頁************************



將http://10.1.5.203/jenkins 引導到8081

在default的最尾巴加上proxy的設定



#sudo vi /etc/apache2/sites-available/default







...



ServerName ci.company.com

ServerAlias ci

ProxyRequests Off



Order deny,allow

Allow from all



ProxyPreserveHost on

ProxyPass /jenkins http://localhost:8081/jenkins







#sudo a2ensite default



參考http://www.zzorn.net/2009/11/setting-up-hudson-on-port-80-on-debian.html

沒有留言: