3

I am trying to set up Jenkins CI for a playframework.org application but am having trouble properly launching play after the auto-test command is run.

The tests all run fine, but it seems as though my script is launching both play auto-test and play start --%ci at the same time. When the play start --%ci command runs, it gets a pid and everything, but it's not running.

FILE: auto-test.sh, jenkins runs this with execute shell

#!/bin/bash
# pwd is jenkins workspace dir
# change into approot dir
cd customer-portal;

# kill any previous play launches
if [ -e "server.pid" ]
then
    kill `cat server.pid`;
    rm -rf server.pid;
fi

# drop and re-create the DB
mysql --user=USER --password=PASS --host=HOSTNAME < ../setupdb.sql

# auto-test the most recent build
/usr/local/lib/play/play auto-test;

# this is inadequate for waiting for auto-test to complete?
# how to wait for actual process completion?
# sleep 60;
wait;

# Conditional start based on tests
# Launch normal on pass, test on fail
#
if [ -e "./test-result/result.passed" ]
then
    /usr/local/lib/play/play start --%ci;
    exit 0;
else
    /usr/local/lib/play/play test;
    exit 1;
fi
notbrain
  • 3,366
  • 2
  • 32
  • 42
  • 1
    Seems to be more an issue with my lack of bash scripting skillz than anything else...looks like the build script isn't terminating and basically sitting and waiting like it was run in the foreground. I had Jenkins console output was showing a persistent log of a running app! No good... – notbrain Mar 18 '11 at 23:26
  • 'play test' --> 'play test app-name --%test' instead so it runs in the background. – notbrain Mar 19 '11 at 00:04

2 Answers2

3

Maybe the sleep time is not enough.

Try using wait instead. You can specify the PID of play auto-test if you can get it, or ask it to wait until all background processes are over.

Look here: http://unstableme.blogspot.com/2008/06/bash-wait-command.html

Sagar
  • 9,456
  • 6
  • 54
  • 96
  • Thanks, but I'm still seeing the same behavior with a wait; without params, not exactly sure how to get at the pid for auto-test but will try to work from ps aux grep magic. – notbrain Mar 18 '11 at 22:38
  • If you try `wait ${!}`, you don't need a PID. It will wait for all background processes to finish, so it should automatically wait for play auto-test – Sagar Mar 19 '11 at 21:45
0

Maybe you can try the Jenkins plugin for Play! Framework.

See here (my resolved issue concerning Jenkins and Play!) : CloudBees + PlayFramework + Eclipse

And here : https://wiki.jenkins-ci.org/display/JENKINS/play-plugin

Community
  • 1
  • 1
Zofren
  • 1,190
  • 2
  • 11
  • 22