Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Generally, if one <strong>Build Step</strong> fails, the rest will not be executed.</p> <p>Pay attention to this line from your log:</p> <pre><code>[VG5] $ /bin/sh -xe </code></pre> <p>The <code>-x</code> makes the shell print each command in console before execution.<br> The <code>-e</code> makes the shell exit with error if any of the commands failed.</p> <p>A "fail" in this case, would be a return code of not 0 from any of the individual commands.<br> You can verify this by running this directly on the machine:</p> <pre><code>./Application --gtest_output=xml echo $? </code></pre> <p>If the <code>echo $?</code> displays 0, it indicates successful completion of the previous command. If it displays anything else, it indicates an error code from the previous command (from ./Application), and Jenkins treats it as such.</p> <p>Now, there are several things at play here. First is that your second Build Step (essentially a temporary shell script <code>/tmp/hudson4729703161621217344.sh</code>) is set to fail if one command fails (the default behaviour). When the Build Step fails, Jenkins will stop and fail the whole job.</p> <p>You can fix this particular behaviour by adding <code>set +e</code> to the top of your second Build Step. This will not cause the script (Build Step) to fail due to individual command failure (it will display an error for the command, and continue).</p> <p>However, the overall result of the script (Build Step) is the exit code of the last command. Since in your OP, you only have 2 commands in the script, and the last is failing, it will cause the whole script (Build Step) to be considered a failure, despite the <code>+x</code> that you've added. Note that if you add an <code>echo</code> as the 3rd command, this would actually work, since the last script command (echo) was successful, however this "workaround" is not what you need.</p> <p>What you need is proper error handling added to your script. Consider this:</p> <pre><code>set +e cd $WORKSPACE/bin &amp;&amp; ./Application --gtest_output=xml if ! [ $? -eq 0 ]; then echo "Tests failed, however we are continuing" else echo "All tests passed" fi </code></pre> <p>Three things are happening in the script:</p> <ol> <li><p>First, we are telling shell not to exit on failure of individual commands</p></li> <li><p>Then i've added basic error handling in the second line. The <code>&amp;&amp;</code> means "execute <code>./Application</code> if-and-only-if the previous <code>cd</code> was successful. You never know, maybe the bin folder is missing, or whatever else can happen. BTW, the <code>&amp;&amp;</code> internally works on the same error code equals 0 principle</p></li> <li><p>Lastly, there is now proper error handling for the result of <code>./Application</code>. If the result is not 0, then we show that it had failed, else we show that it had passed. Note, this since the last command is not a (potentially) failing <code>./Application</code>, but an <code>echo</code> from either of if-else possibilities, the overall result of the script (Built Step) will be a success (i.e 0), and the next Build Step will be executed.</p></li> </ol> <p>BTW, you can as well put all 3 of your build steps into a single build step with proper error handling.</p> <p>Yes... this answer may be a little longer than what's required, but i wanted you to understand how Jenkins and shell treat exit codes.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload