-
Bug
-
Resolution: Unresolved
-
Minor
-
None
I have a Jenkins job where I'm running Ansible through sshCommand:
sshCommand remote: remote, command: "ansible-playbook lb.yml"
However, if the last step of this Ansible playbook fails, the plugin throws an exception, but doesn't print the error logs for that final step. Running it normally in a shell would print additional logs.
Jenkins log:
TASK [lb : Configure nginx conf] ****************************************** changed: [server] TASK [lb : Restart nginx] ************************************************* [Pipeline] } [Pipeline] // withCredentials [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from <server-ip> at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741) at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356) at hudson.remoting.Channel.call(Channel.java:955) at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:72) at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84) ... (additional stack trace lines omitted) org.hidetake.groovy.ssh.session.BadExitStatusException: Command returned exit status 2: ansible-playbook lb.yml
Shell log:
TASK [lb : Configure nginx conf] ****************************************** changed: [server] TASK [lb : Restart nginx] ************************************************* fatal: [server]: FAILED! => {"changed": false, "msg": "Unable to start service nginx: Job for nginx.service failed because the control process exited with error code.\nSee \"systemctl status nginx.service\" and \"journalctl -xe\" for details.\n"} to retry, use: --limit @/ansible/lb.retry PLAY RECAP **************************************************************** server : ok=1 changed=0 unreachable=0 failed=1
I checked, and all of these log lines go to stdout.
These additional log lines are necessary for debugging the issue (the workaround right now is to try executing the ansible script directly from the node, which isn't great) so it would be great to flush them before throwing this BadExitStatusException.
- relates to
-
JENKINS-57765 No output returned from sshCommand
-
- Closed
-
jiangtyd Thank you for reporting this. This is a kind of known behavior and workaround is to wait a couple of seconds at the end of the pipeline to catch up on the logs. For more info refer the comment on this old Jira https://issues.jenkins-ci.org/browse/JENKINS-57765
Let me know if you are still facing the issue after applying this workaround.. Thank you again.