Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54929

Some final output is missing in Jenkins Pipeline when using the Ansible Plugin

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • ansible-plugin
    • Latest (11.29.18) Jenkins Version 2.153 (2018-11-25)
      Latest (11.29.18) Jenkins Ansible Pipeline plugin Version 1.0 (26 March 2018)
    • 148.v6b_13c6de3a_47

      When using the Ansible Plugin with jenkins Pipeline,
      I can't see the entire log on Jenkins PIpeline build output - Some output is missing at the end of the Ansible play.
      The output looks fine on a terminal - if I'll SSH to the server and run the ansible-playbook command from the command line.

      • This issue started about a month ago..

      Here is a screenshot of how the output look like now:
      https://imgur.com/waX7XcM

      Ansible Plugin:
      https://jenkins.io/doc/pipeline/steps/ansible/

      This is the Pipeline code that uses the Ansible Pipeline Plugin:

              stage('running something') {
                  steps {
                      script {
                          dir('my/path/here') {
                              ansiblePlaybook([
                                      inventory   : 'hosts',
                                      playbook    : 'main.yml',
                                      installation: 'ansible',
                                      sudoUser    : null,
                                      colorized   : true,
                                      extraVars   : [
                                              blah   : "${params.blah}",
                                              some_var       : "${params.some_var}"
                                      ]
                              ])
                          }
                      }
                  }
              }
      

          [JENKINS-54929] Some final output is missing in Jenkins Pipeline when using the Ansible Plugin

          Ben Specht added a comment -

          I'm seeing the same behavior.


          System info:
          Ansible Pipeline plugin Version 1.0
          Jenkins version 2.138.3
          Pipeline version 2.6

          Ben Specht added a comment - I'm seeing the same behavior. System info: Ansible Pipeline plugin Version 1.0 Jenkins version 2.138.3 Pipeline version 2.6

          Looks like if there is another step after the ansible-playbook call, the missing output gets printed out at some point, but later than it should (please see the two attached images)

          If the ansible-playbook is the last step in the pipeline, or if it exits with error, the text is left missing.

          Andrei Gheorghiu added a comment - Looks like if there is another step after the ansible-playbook call, the missing output gets printed out at some point, but later than it should (please see the two attached images) If the ansible-playbook is the last step in the pipeline, or if it exits with error, the text is left missing.

          Adam Delarosa added a comment -

          adghdevAndrei Gheorghiu For me, In Blue Ocean, I see the output as bad as at standard output..

          Adam Delarosa added a comment - adghdev Andrei Gheorghiu For me, In Blue Ocean, I see the output as bad as at standard output..

          I also have the same issue

          Ansible Pipeline plugin Version 1.0
          Jenkins version 2.138.2
          Pipeline: Declarative 1.3.4

           

          Ruslan Bondarau added a comment - I also have the same issue Ansible Pipeline plugin Version 1.0 Jenkins version 2.138.2 Pipeline: Declarative  1.3.4  

          Same issue here.

           

          Ansible plugin 1.0

          Ansible 2.5.6

           

          Jenkins Blue output:

          Local session:

          Benjamin Debotte added a comment - Same issue here.   Ansible plugin 1.0 Ansible 2.5.6   Jenkins Blue output: Local session:

          Pablo Sanchez added a comment -

          I am seeing the same, hardcoded Ansible commands shows proper output but the plugin doesn't

          Pablo Sanchez added a comment - I am seeing the same, hardcoded Ansible commands shows proper output but the plugin doesn't

          honey badger added a comment -

          Hello,

          We are facing the same issue on our jenkins.

          We checked many versions and the bug is visible from the version LTS 2.138.1.

          • 2.138.4 nok
          • 2.138.3 nok
          • 2.138.2 nok
          • 2.138.1 nok
          • 2.121.3 ok

          Another interesting fact is that the bug is not present on pipeline ran from the master. It only affects remote executions.

           

          This issue may be related to the following fix:

          https://github.com/jenkinsci/jenkins/commit/ebd71116c15b97fd3e855a738fbfdef387cd6e3c

          I reverted the commit and recompiled the latest version and now I'am able to see the full log (but some logs remain overwritten by the ssh-agent).

          I do not know if this FIX JENKINS-52729 is directly involved to our bug. Maybe jglick could help on that issue.

          honey badger added a comment - Hello, We are facing the same issue on our jenkins. We checked many versions and the bug is visible from the version LTS 2.138.1. 2.138.4 nok 2.138.3 nok 2.138.2 nok 2.138.1 nok 2.121.3 ok Another interesting fact is that the bug is not present on pipeline ran from the master. It only affects remote executions.   This issue may be related to the following fix: https://github.com/jenkinsci/jenkins/commit/ebd71116c15b97fd3e855a738fbfdef387cd6e3c I reverted the commit and recompiled the latest version and now I'am able to see the full log (but some logs remain overwritten by the ssh-agent). I do not know if this FIX  JENKINS-52729 is directly involved to our bug. Maybe jglick could help on that issue.

          Jesse Glick added a comment -

          Not familiar with this plugin so cannot give details, but in general if you have a Callable (or FileCallable) running on an agent that has been passed a serialized TaskListener, it will need to flush before returning.

          Jesse Glick added a comment - Not familiar with this plugin so cannot give details, but in general if you have a Callable (or FileCallable ) running on an agent that has been passed a serialized TaskListener , it will need to flush before returning.

          Konrad Mosoń added a comment -

          I've experienced this problem too ;(

          Konrad Mosoń added a comment - I've experienced this problem too ;(

          Sven Hergenhahn added a comment - - edited

          Mee too. Since usually when a problem occurs, the output at the end is important, I've for now resorted to using ansible-playbook with sh 'ansible-playbook ...' in my pipeline and since have no problem with my output.

          I would prefer to return to the plugin though if possible

          Sven Hergenhahn added a comment - - edited Mee too. Since usually when a problem occurs, the output at the end is important, I've for now resorted to using ansible-playbook with sh 'ansible-playbook ...' in my pipeline and since have no problem with my output. I would prefer to return to the plugin though if possible

          Pablo Sanchez added a comment -

          What I did to solve this, instead of manually calling Ansible from the Pipeline I extended the pipeline with a library method which calls Ansible.

          Something like:

          class Ansible implements IAnsible{    
              def context
              Map arguments    
              def ansiblePlaybook
              def ansibleInventory
              def ansibleExtras
              def ansibleExtraVars    
          
              Ansible(Map arguments, context){
                  this.context = context
                  this.arguments = arguments    
              }
          
              void parseArguments(Map arguments){
                  ansiblePlaybook = arguments.get("playbook", '')
                  ansibleInventory = arguments.get("inventory", '')
                  ansibleExtras = arguments.get("extras", '')
                  ansibleExtraVars = arguments.get("extraVars", '')
              }    
          
              String parseAnsibleExtraVars(Map extras){
                  def sb = new StringBuilder()        
                  sb.append('\'')
                  ansibleExtraVars.each(){ key, value ->
                      sb.append(key)
                      sb.append('=')
                      sb.append(value)
                      sb.append(' ')
                  }
                  sb.append('\'')        
                  return sb.toString()
              }    
          
              void playbookCall(){
                parseArguments(this.arguments)        
                def extraVars = parseAnsibleExtraVars(ansibleExtraVars)        
                context.sh """ export ANSIBLE_FORCE_COLOR=1 \ 
                  && ansible-playbook -i ${ansibleInventory} ${ansiblePlaybook} --extra-vars ${extraVars}    ${ansibleExtras} """    
             }
          }
          

          And you call it pretty much in the same way from the pipeline, just create a method in vars:

          // code placeholder
          import com.ansible.Ansible
                  def call(Map ansibleParameters){
                      def ansibleRunner = new Ansible(ansibleParameters, this)
                      ansiColor('xterm') {
                          ansibleRunner.playbookCall()
                      }
                  }
          

           

           

          Pablo Sanchez added a comment - What I did to solve this, instead of manually calling Ansible from the Pipeline I extended the pipeline with a library method which calls Ansible. Something like: class Ansible implements IAnsible{ def context Map arguments def ansiblePlaybook def ansibleInventory def ansibleExtras def ansibleExtraVars Ansible(Map arguments, context){ this .context = context this .arguments = arguments } void parseArguments(Map arguments){ ansiblePlaybook = arguments.get( "playbook" , '') ansibleInventory = arguments.get( "inventory" , '') ansibleExtras = arguments.get( "extras" , '') ansibleExtraVars = arguments.get( "extraVars" , '') } String parseAnsibleExtraVars(Map extras){ def sb = new StringBuilder() sb.append( '\' ') ansibleExtraVars.each(){ key, value -> sb.append(key) sb.append( '=' ) sb.append(value) sb.append( ' ' ) } sb.append( '\' ') return sb.toString() } void playbookCall(){ parseArguments( this .arguments) def extraVars = parseAnsibleExtraVars(ansibleExtraVars) context.sh """ export ANSIBLE_FORCE_COLOR=1 \ && ansible-playbook -i ${ansibleInventory} ${ansiblePlaybook} --extra-vars ${extraVars} ${ansibleExtras} """ } } And you call it pretty much in the same way from the pipeline, just create a method in vars: // code placeholder import com.ansible.Ansible def call(Map ansibleParameters){ def ansibleRunner = new Ansible(ansibleParameters, this ) ansiColor( 'xterm' ) { ansibleRunner.playbookCall() } }    

          Steven Clark added a comment - - edited

          I've submitted a PR that addresses this issue at least for me (https://github.com/jenkinsci/ansible-plugin/pull/29).Hopefully someone could accept it and create a bugfix release with it. 

           

          EDIT: Looks like there are a few different cases, the patch in that PR seemed to address at least one, but we are still seeing some trimmed output depending on how Ansible might have died from the looks of things. I'll keep on looking into the plugin but for now I've pulled the PR.

          Steven Clark added a comment - - edited I've submitted a PR that addresses this issue at least for me ( https://github.com/jenkinsci/ansible-plugin/pull/29 ).Hopefully someone could accept it and create a bugfix release with it.    EDIT:  Looks like there are a few different cases, the patch in that PR seemed to address at least one, but we are still seeing some trimmed output depending on how Ansible might have died from the looks of things. I'll keep on looking into the plugin but for now I've pulled the PR.

          I had to switch to `sh` as well

          Viacheslav Subotskyi added a comment - I had to switch to `sh` as well

          Steven Clark added a comment -

          So we've been running with the latest PR (https://github.com/jenkinsci/ansible-plugin/pull/30) I created for the past two weeks and this new version of the PR seems to solve the issue.

           

          Is it possible to get the maintainer to look through the PR to get a new release of the plugin?

           

          Steven Clark added a comment - So we've been running with the latest PR ( https://github.com/jenkinsci/ansible-plugin/pull/30 ) I created for the past two weeks and this new version of the PR seems to solve the issue.   Is it possible to get the maintainer to look through the PR to get a new release of the plugin?  

          Eyal Goren added a comment -

          I wanted to use the plugin, but our deployments need to run some commands on Websphere, and in case of failures the plugin does not show the error log, so I needed to move to sh as well.

           

          Waiting for the new release.

          Eyal Goren added a comment - I wanted to use the plugin, but our deployments need to run some commands on Websphere, and in case of failures the plugin does not show the error log, so I needed to move to sh as well.   Waiting for the new release.

          Daniel added a comment -

          This is still a major bug - the fix is apparently here (https://github.com/jenkinsci/ansible-plugin/pull/30), please could it get reviewed? 

          Daniel added a comment - This is still a major bug - the fix is apparently here ( https://github.com/jenkinsci/ansible-plugin/pull/30 ), please could it get reviewed? 

          Hi,

          I'm now maintainer of this plugin. I would like to test it and release a new version in the next fews days.

          Best regards,

          Valentin Delaye added a comment - Hi, I'm now maintainer of this plugin. I would like to test it and release a new version in the next fews days. Best regards,

            jonesbusy Valentin Delaye
            nimitack Adam Delarosa
            Votes:
            15 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved: