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

Unclear error message "Array has 0 entries, requires minimum of 1" when creating new Parallel stage groups

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • Blue Ocean 1.3

      Summary:
      When creating a new Parallel Group for a pipeline, the editor produces an error stating "Array has 0 entries, requires minimum of 1" until a nested stage actually gets created. This error message, while technically true, isn't helpful to the user. Especially if that user is new to Pipelines, and might not even know what an array is, much less be able to make the leap that we're talking about an "array of pipeline stages inside of a parallel block."

      Steps to recreate:
      1. Connect Jenkins to a remote Git repository which already contains a Jenkinsfile which includes parallel stages, compliant with Declarative 1.2. Note that I was not able to recreate this problem by starting with a bare repo, so it's possible that having a Jenkinsfile already in place is a prerequisite. I'll provide the one I was using at the bottom of the body of this description.

      2. After building the Pipeline, edit it:

      3. Click the button:

      4. Then click the button below it:

      5. You'll be asked for a name for your Parallel Group. Provide one and click Create. To the right, there's an error, which reads "Array has 0 entries, requires minimum of 1":

      6. If you add a step to your Parallel group, like shown below, the warning triangle moves down one "layer," presumably to the first of n number of parallel stages:

      The Jenkinsfile I was using looked exactly like this when I first connected Jenkins to the repository:

      // library('declarative-libs')
      
      pipeline {
      
          parameters {
              string(name: 'String parameter with spaces', defaultValue: 'Fill me in with something witty!', description: 'This is a string parameter, yo!')
              booleanParam(name: 'TRUE_OR_FALSE', defaultValue: true, description: 'This boolean defaults to true!') 
              string(name: 'AGENT_NAME', defaultValue: 'linux', description: 'Where to run')
          }
      
          agent {
              label ("${env.AGENT_NAME}")
          }
      
          environment {
              // AGENT_NAME="linux"
              SOMETHING_TO_INHERIT  = "This has been inherited!"
              SOMETHING_TO_OVERRIDE = "This should be overriden, if you see it, that's wrong."
          }
      
          options {
              buildDiscarder(logRotator(numToKeepStr: '100')) 
              disableConcurrentBuilds()
              timestamps()
          }
      
          triggers {
              pollSCM('*/10 * * * *')
          }
      
          tools {
              jdk 'jdk8'
          }
      
          stages {
              stage ('Parallel Wrapper') {  // start of parallel wrapper
                  parallel {
                      stage('parallel-1') {
                          steps {
                              echo "Let's check our environment variables"
                              echo SOMETHING_TO_INHERIT
                              echo SOMETHING_TO_OVERRIDE
                              sleep 2
                          }
                      }
                      stage('parallel-2 OVERRIDES') {
                          environment {
                              SOMETHING_TO_OVERRIDE = "YES --> PARALLEL-2"
                          }
                          steps {
                              echo "Let's check our environment variables"
                              echo SOMETHING_TO_INHERIT
                              echo SOMETHING_TO_OVERRIDE
                              sleep 2
                          }
                      }
                      stage('parallel-3 OVERRIDES') {
                          environment {
                              SOMETHING_TO_OVERRIDE = "YES --> PARALLEL-3"
                          }
                          steps {
                              echo "Let's check our environment variables"
                              echo SOMETHING_TO_INHERIT
                              echo SOMETHING_TO_OVERRIDE
                              sleep 2
                          }
                      }
                  } // end of parallel
              } // end of wrapper stage
          } // end stages
          
          // This section is evaluated after the stages are all done.
          post {
              always {
                  echo "ALWAYS --> Runs all the time."
              }
              success {
                  echo "SUCCESS --> Whatever we did, it worked. Yay!"
              }
              failure {
                  echo "FAILURE --> Failed. Womp womp."
              }
          }
       }
      

            kshultz Karl Shultz
            kshultz Karl Shultz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: