Jenkins
Jenkins is a good tool for continuous integrations and system build.
Install from Installing Jenkins on Ubuntu
Configration file:
sudo vi /etc/default/jenkins
# You could change the port from HTTP_PORT variable
Nginx configuration:
upstream app_server {
server 127.0.0.1:8082 fail_timeout=0;
}
server {
listen 80;
server_name jenkins_server;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
}
Setting up a secured Jenkins instance
Manage Jenkins -> Configure Global Security:
- Check Enable security
- Click Jenkins' own user database
- Check Allow users to sign up
- Save
- Sign up new account
- After sign up an account uncheck Allow users to sign up
Git, Bitbucket and Jenkins:
Enable these plugins:
- Git Plugin
- GitBucket Plugin
Setup Project from configuration to pull repositories from Git and put the urls and credential.To trigger builds when pushing commit:
-
Create API token for the user from user configuration
-
Create API token for the project from project configuration
-
From Bitbucket go to settings -> hooks create new jenkins hook.
- Endpoint: http://username:[email protected]_server
- Project name: Project name in Jenkins
- Token: Project token
Python Project
First you need to install virtualenv on the server
Build script:
echo "Start build scripts"
PYENV_HOME=$WORKSPACE/.venv/
if [ ! -d $PYENV_HOME ]; then
virtualenv --no-site-packages $PYENV_HOME
fi
. $PYENV_HOME/bin/activate
pip install --quiet -r requirements.txt --download-cache=/tmp/$JOB_NAME
echo "END build scripts"
Ref:
- http://felixleong.com/blog/2012/02/hooking-bitbucket-up-with-jenkins
- http://blogs.steeplesoft.com/posts/2014/02/05/integrating-bitbucket-and-jenkins/
- https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
- http://iamnearlythere.com/jenkins-python-virtualenv/
- http://www.alexconrad.org/2011/10/jenkins-and-python.html