How do I trigger a "behave" test from a Jenkins Execute Shell build step?

Viewed 2930

I have a series of BDD selenium tests that run using a selenium standalone server. To run them, I enter the following code in the terminal (once I'm in the right directory):

source project/bin/activate # Opens a virtualenv with appropriate interpreters
behave

and when the tests are done:

deactivate # Ends the virtualenv

I have configured a Jenkins project that accesses a GitHub repo with the same files and tests. In the project there is a build step that executes a shell command. The code there is:

#!/bin/bash
cd dev                        #Enter right directory
source project/bin/activate   #Activate virtualenv
behave

see Execute Shell Build step

However, when I build the project I get the following output:

Started by <user>
Building in workspace /Users/Shared/Jenkins/Home/workspace/Tutorial
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@github.com:<url>.git # timeout=10
Fetching upstream changes from git@github.com:<url>.git
> git --version # timeout=10
> git fetch --tags --progress git@github.com:<url>.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b62c3e873be4fba3daa1b29a9954a130c768a8f4 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f b62c3e873be4fba3daa1b29a9954a130c768a8f4
> git rev-list b62c3e873be4fba3daa1b29a9954a130c768a8f4 # timeout=10
[Tutorial] $ /bin/bash /Users/Shared/Jenkins/tmp/hudson719949293776127111.sh
/Users/Shared/Jenkins/tmp/hudson719949293776127111.sh: line 4: behave: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

see Console Output

I've tried variations and seem to always get a similar results. How do I get these tests run?

Edit:

I've also tried creating a shell script (run.sh) that runs behave with the following code:

#!/bin/sh
exec project/bin/behave

and then running the script in the Jenkins build step with the code ./run.sh instead of behave or the variations I mentioned in the comments, but I get the same errors.

1 Answers
Related