'How to get python3 on jenkins?
I am new to Jenkins. I installed python plugin which is available from Jenkins UI. But seems like it install python 2. I want to have python 3 on Jenkins. I haven't find anything on internet relevant. There are couple of question on similar lines but none of them have proper answers.
Solution 1:[1]
There are multiple ways to achieve the above
- Python plugin (for my experience not very helpful nor widely used)
- Install Docker on Agent + Shell + virtualenv (with or without pipelines)
- Shell + Docker (with or without pipelines)
I'll add links to docs & example to 3. which I consider modern jenkins way as it allows you mix and match python versions and package dependencies
Example:
// // Modern jenkins python example - utilizing Pipelines and Docker agent(python:3) // pipeline { agent { docker { image 'python:3' label 'my-build-agent' } } stages { stage('Test') { steps { sh """ python --version python ./test.py """ } } } }
Docs to get more involved with the above:
https://www.jenkins.io/doc/book/pipeline/getting-started/
https://www.jenkins.io/doc/book/pipeline/docker/
Solution 2:[2]
In my experience, the best way to do it is to write a shell script for what you need to do and then call this shell script from Jenkins as a "shell command" step.
It's simple, it puts you in control and it gives you everything you need. You are not limited by what Jenkins provides, it works great with virtualenv
and your developers can run the same script on their computers which is also extremely helpful.
You can commit this script as part of the project in your repository.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | vijay |
Solution 2 | jurez |