Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make jenkins run a python script that executes a build?

Learning Jenkins, and trying to get it to build a project for which my build script is written in python.

./build.py -i

I've tried using the 'Execute script' and 'Execute Python script'. The script first line is

#!/usr/bin/python

Jenkins doesn't complain about either attempt, it just seems to ignore the setting, declaring the build successful as soon as the code is checked out.

I've read a few old mail lists that hint that I'll have to write a bash script (build.sh) and have it call the python script. I hope that's not the answer.

like image 372
CAB Avatar asked May 02 '12 21:05

CAB


People also ask

Can we use Python in Jenkins?

In the Python ecosystem there are tools which can be integrated into Jenkins for testing/reporting such as: nose2 and pytest for executing unit tests and generating JUnit-compatible XML test reports and Cobertura-compatible code coverage reports.


1 Answers

You should be able to use an "Execute shell" build step and specify /path/to/build.py -i

I'm guessing that the current directory when the build job runs isn't what you're expecting. Jenkins has a built-in environment variable WORKSPACE that is set to the root of the build's workspace, so assuming that the Python script is at the root of your checked out code, $WORKSPACE/build.py should also work.

like image 174
gareth_bowles Avatar answered Oct 11 '22 23:10

gareth_bowles