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:

 1 <execution>
 2   <id>setuptools test</id>
 3   <phase>test</phase>
 4   <goals>
 5     <goal>exec</goal>
 6   </goals>
 7   <configuration>
 8     <skip>${maven.test.skip}</skip>
 9     <arguments>
10       <argument>setup.py</argument>
11       <argument>nosetests</argument>
12     </arguments>
13   </configuration>
14 </execution>

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

1 setup(
2     # ...
3     setup_requires = [
4         'nose >= 1.0',
5     ]
6 )

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

1 [nosetests]
2 with-xunit = true
3 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:

/media/blog/38/new_job.png

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).
/media/blog/38/job.png

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:

/media/blog/38/job_tab.png

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

/media/blog/38/build_now_tag.png

Same principles can applies to create a deployment job.

In addition to a Hosted Continuous Integration Service, ShiningPanda 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!

Comments

No comments yet.

Post your comment