Python & Java: a unified build process (4/4)

In our previous blog posts dedicated to Python and Java (see the first, second and third, we saw how to get a fully functional build, release and deployment workflow with Maven.

Integration

It's now time to introduce Jenkins and see how can we put our sample project in integration.

First of all, Jenkins needs some parseable test results. In Java, the maven-surefire-plugin handles this by default. In Python, nose will generate them for us.

Modify setuptools/pom.xml to call python setup.py nosetests instead of python setup.py test on test phase:

<execution>
  <id>setuptools test</id>
  <phase>test</phase>
  <goals>
    <goal>exec</goal>
  </goals>
  <configuration>
    <skip>${maven.test.skip}</skip>
    <arguments>
      <argument>setup.py</argument>
      <argument>nosetests</argument>
    </arguments>
  </configuration>
</execution>

Then edit the setup.py of Python projects to add the nose dependency:

setup(
    # ...
    setup_requires = [
        'nose >= 1.0',
    ]
)

Finally create or update a setup.cfg file along the setup.py and add the following lines:

[nosetests]
with-xunit = true
xunit-file = TEST-nosetests.xml

Note the xunit-file value that matches the pattern of the reports generated by maven-surefire-plugin

Time to create a New Job on Jenkins:

image

Configure:

  • the source: git://github.com/shiningpanda/tutorial-python-java.git,
  • the build trigger policy: scm polling every five minutes,
  • the build steps: we are using the Virtualenv Builder of the ShiningPanda Plugin. This builder creates an isolated Python environment with virtualenv, so installed packages won't conflict with the ones installed on the system. Then we simply add the following Maven call in it: mvn clean install,
  • the post-build actions: to ask Jenkins to parse and display the test results (note the pattern).

image

Then click on Save and Build Now and that's it.

Release and Deployment

Jenkins can also be helpful to run the release and deployment tasks. Here is a sample job configuration to tag the project:

image

Note the parameters allowing the user to input the desired versions for the release:

image

Same principles can applies to create a deployment job.

In addition to a Hosted Continuous Integration Service, ShiningPanda CI is also offering build and release management expertise, so if you have questions or if you are stuck with your internal build process do not hesitate to contact our service team!