Uncategorized

Establishing Python CI Build in Jenkins

Setting up project build in Jenkins is very easy – there are a lot of plugins fow varioous languages, notification, pre and post build actions. But the most important path is Build Action itself.

Build Action for Python Project Build with Unit Test and Code Analysis

PYENV_HOME=$WORKSPACE/.pyenv/

# Delete previously built virtualenv
if [ -d $PYENV_HOME ]; then
    rm -rf $PYENV_HOME
fi

# Create virtualenv and install necessary packages
virtualenv --no-site-packages $PYENV_HOME
. $PYENV_HOME/bin/activate
pip install --quiet -r requirements.txt 
pip install --quiet nosexcover
pip install --quiet pylint
nosetests --with-xunit --cover-package=myapp --cover-erase --with-xcoverage ./test 
pylint -f parseable myapp/ | tee pylint.out

Build Action for Python Module Build with Unit Test and Code Analysis

PYENV_HOME=$WORKSPACE/.pyenv/

# Delete previously built virtualenv
if [ -d $PYENV_HOME ]; then
    rm -rf $PYENV_HOME
fi

# Create virtualenv and install necessary packages
virtualenv --no-site-packages $PYENV_HOME
. $PYENV_HOME/bin/activate
pip install --quiet nosexcover
pip install --quiet pylint
pip install --quiet $WORKSPACE/  # where your setup.py lives
nosetests --with-xunit --cover-package=myapp --cover-erase --with-xcoverage ./tests
pylint -f parseable myapp/ | tee pylint.out

Post-Build Actions for Both Configurations

**/nosetests.xml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s