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

          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: