Use of Python in Pipeline to get away from groovy and bash

The group I work with at present is using Jenkins for a variety of projects. We all come from diverse backgrounds but the common element is that the majority of our projects are in Python. To have coverage of programmer resources we would like to see if everything that we currently have in Jenkins Pipelines that is in Groovy and Bash be moved to Python.

Can anyone provide resources and/or comments about this undertaking. I am currently learning groovy but this is simply not the answer. Our schedules do not allow us to simply drop support to our user base to controller either bash or groovy to get our Jenkins work done.

I would appreciate links to resources on using python in a Jenkins pipeline to take the place of groovy or bash.

Thanks to all.

The only way you could do things in Python is to launch Python scripts from pipeline. There is no option to develop pipelines directly in Python. You can always sh 'python someScript.py' in your pipelines and do the majority of the build operations there. If you rely on things like junit reports and so forth, you would have to still do those in groovy in either a Jenkinsfile or inline pipeline script.

Thanks for the insight. What about if you start up the agent with python – does this not allow scripting in python in the pipeline?

Joseph Norris

623-203-8866

No, nothing will allow you to script pipelines in python. You can definitely do most of your work in python scripts (calling make, Scons, etc), but they must be launched from an sh step.

We are doing tons of Python data science, both locally on the Jenkins server as well by delegating jobs to our Linux HPC cluster job arrays. There is nothing wrong with using Groovy and Bash (and in my case PoweShell) to launch external Python scripts and applications. Groovy is for Jenkins what yeast is for bread. Learn how to use it effectively and you’ll never go hungry :baguette_bread::grin: