logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$30
How do I get the exit status of a task called at command line?

Not really a Symfony question, but I am dealing with this with both Symfony tasks and also other PHP scripts that are called via the command line.

Here is the problem: these scripts are being called from Jenkins

Jenkins assumes a script was successful if its exit status was zero. A PHP script that returns nothing is the same as a script that returns zero. So some failing scripts are being treated successes in Jenkins. I need to return "1" so we can trigger Jenkins automated responses for failures.

I changed the scripts to they "return 1" whenever they fail (wrapped in try{}catch{} blocks, I return 1 from the catch blocks).

From Jenkins, we call the script like this:

sudo su - www-data -c "cd /usr/wonderful/wonderful.com/scripts && /usr/bin/php events_feed_to_scripts_server.lawrence.php"


I am unable to get Jenkins to see that the inner script is returning "1". Any thoughts about how to re-organize this?

This question has been answered.

Lawrence Krubner | 01/08/13 at 5:12pm Edit
Tutorial: How to assign prize money


(3) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    01/08/13
    5:14pm
    Luis Cordova says:

    > echo $

    or something

  • avatar
    Last edited:
    01/08/13
    5:48pm
    Milena Dimitrova says:

    This should be enough to produce output '1':

    	echo 1;
    exit();


    You can remove "return 1" from the catch blocks, just use echo and exit.

    You can also remove the parentheses after exit if you wish and use it as a language construct.

  • avatar
    Last edited:
    01/08/13
    6:03pm
    Joshua Estes says:

    http://us3.php.net/exit

This question has expired.



Lawrence Krubner voted on this question.



Current status of this question: Completed



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.