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

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

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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}"
                                      ]
                              ])
                          }
                      }
                  }
              }
      

        Attachments

        1. ansible-plugin.PNG
          ansible-plugin.PNG
          39 kB
        2. ansible-plugin-blue-ocean.PNG
          ansible-plugin-blue-ocean.PNG
          50 kB
        3. ansible-plugin-moved-output.PNG
          ansible-plugin-moved-output.PNG
          37 kB
        4. image-2019-01-07-13-55-02-950.png
          image-2019-01-07-13-55-02-950.png
          62 kB
        5. image-2019-01-07-13-55-28-725.png
          image-2019-01-07-13-55-28-725.png
          19 kB
        6. Screen Shot 2018-12-04 at 11.09.00 AM.png
          Screen Shot 2018-12-04 at 11.09.00 AM.png
          153 kB
        7. Selection_026.jpg
          Selection_026.jpg
          94 kB
        8. waX7XcM.png
          waX7XcM.png
          103 kB

          Issue Links

            Activity

            Hide
            jglick 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.

            Show
            jglick 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.
            Hide
            morsik Konrad Mosoń added a comment -

            I've experienced this problem too ;(

            Show
            morsik Konrad Mosoń added a comment - I've experienced this problem too ;(
            Hide
            svenxy 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

            Show
            svenxy 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
            Hide
            pablosan 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()
                        }
                    }
            

             

             

            Show
            pablosan 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() } }    
            Hide
            stevendpclark 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.

            Show
            stevendpclark 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.

              People

              • Assignee:
                sirot Jean-Christophe Sirot
                Reporter:
                nimitack Adam Delarosa
              • Votes:
                11 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated: