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

Generating tasks in "for in" loop and executing them in parallel SOMETIMES causes failure of successfull task if another one failed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • groovy-plugin
    • Jenkins 2.150.1, Pipeline-Groovy Plugin 2.57

      I have four jobs - 2 for windows and 2 for linux agents. These are simple test jobs: just copy one file to another directory, sleep 10 seconds and echo "successfull".
      One of the linux jobs is intentionally wrong - path to file is non-existent.
      I try to run these jobs in parallel from pipeline script:

      import jenkins.model.Jenkins
      
      pipeline {
          agent none
          stages {
              stage('Preparing machines') {
                  steps {
                      script {
                          def machines = ['agent-windows0', 'agent-windows1', 'agent-redhat0', 'agent-redhat1']
                          def machinePreparations = [:]
      
                          for (machine in machines) {
                              def agentName = machine
                              def labelParameters = []
                              labelParameters.add([$class: 'NodeParameterValue', name: 'node_name', labels: [agentName], nodeEligibility: [$class: 'AllNodeEligibility']])
                              labelParameters.add([$class: 'StringParameterValue', name: 'ARBITRARY_PARAMETER', value: 'ARBITRARY_VALUE'])
      
                              machinePreparations[agentName] = {
                                  stage(agentName + ' preparation') {
                                      build job: '../Preparation/' + agentName, parameters: labelParameters
      
                                      def node = Jenkins.get().nodes.find({it.name == agentName})
                                      node.setLabelString(node.getLabelString() + 'successful')
                                      println(String.format("Job with machine %s successfully done!", agentName))
                                  }
                              }
                          }
      
                          parallel machinePreparations
                      }
                  }
              }
          }
      }
      

      Sometimes everything goes right - only wrong linux job fails, all other finish successfully.
      But sometimes another linux job is also marked as failed in pipeline tab (See screen attached)
      In the job tab, this job is still successful though.
      In this case, everything, which is supposed to be done within this failed/successfull job is done, but code, which goes after "build job" instruction is not executed

        1. screen.jpg
          screen.jpg
          278 kB
        2. jobAlwaysSuccessful.jpg
          jobAlwaysSuccessful.jpg
          162 kB
        3. log.txt
          3 kB

            vjuranek vjuranek
            alpanshin Alexandr Panshin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: