2

I have a multibranch pipeline set up in Jenkins that runs a Jenkinsfile, which uses pytest for testing scripts, and outputs the results using Cobertura plug-in and checks code quality with Pylint and Warnings plug-in.

I would like to test the code with Python 2 and Python 3 using virtualenv, but I do not know how to perform this in the Jenkinsfile, and Shining Panda plug-in will not work for multibranch pipelines (as far as I know). Any help would be appreciated.

1 Answer 1

1

You can do it even using vanilla Jenkins (without any plugins). 'Biggest' problem will be with proper parametrization. But let's start from the beginning.

2 versions of Python

When you install 2 versions of python on a single machine you will have 2 different exec files. For python2 you will have python and for python3 you will have python3. Even when you create virtualenv (use venv) you will have both of them. So you are able to run unittests agains both versions of python. It's just a matter of executing proper command from batch/bash script.

Jenkins

There are many ways of performing it:

  • you can prepare separate jobs for both python 2 and 3 versions of tests and run them from jenkins file
  • you can define the whole pipeline in a single jenkins file where each python test is a different stage (they can be run one after another or concurrently)
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I have now included separate stages that install my project in the separate versions of Python, and tests can now be run in separate Build stages for each version of Python. Having separate build jobs for each version of Python helps visualise the result of builds separately for Py version 2 or 3.
What directive can one use to run tests concurrently on jenkins?
@Daniel use parallel for stages (jenkins.io/blog/2017/09/25/declarative-1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.