CAB
CAB

Reputation: 1045

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.

Upvotes: 8

Views: 26697

Answers (1)

gareth_bowles
gareth_bowles

Reputation: 21140

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.

Upvotes: 10

Related Questions