title: How to Pass two values from the list in the Jenkins groovy function with loop
body: <p>I want to loop this two lists in Jenkinsfile and get the values with 1:1 mapping . My code is working but i can see repetitive entries in the output.</p>
  <p>I have following two lists in Jenkinsfile</p>
  <pre><code>app = [&quot;app1&quot;,&quot;app2&quot;,&quot;app3&quot;]
  env = [&quot;prod1&quot;,&quot;prod2&quot;,&quot;prod3&quot;]
  </code></pre>
  <p>My Jenkinsfile-</p>
  <pre><code>    #!/usr/bin/env groovy
      @Library(['jenkinsGlobalLibrary@master']) _
      app = [&quot;app1&quot;,&quot;app2&quot;,&quot;app3&quot;]
      env = [&quot;prod1&quot;,&quot;prod2&quot;,&quot;prod3&quot;]
      (branchType, branchName) = env.BRANCH_NAME.tokenize('/')
      
      node('java180u161-maven325-pythonanaconda352') {
      
          stage ( 'Checkout' ) {
      
              checkout scm
          }
      
          stage ('Generating list environment wise'){
               pull_from_dev(app,env)
          }
      
      def pull_from_dev(app,env) {
          sh &quot;echo Going to echo a list&quot;
          for (int i = 0; i &lt; app.size(); i++) {
               for (int j = 0; j &lt; env.size(); j++) {
              sh &quot;&quot;&quot;
              echo &quot;Retrieving   ${app[i]} of ${env[j]} properties &quot;
              &quot;&quot;&quot;   
        }  }
  }
  </code></pre>
  <p>My output -</p>
  <pre><code>Retrieving app1 of prod1 properties 
  Retrieving app1 of prod1 properties 
  Retrieving app1 of prod1 properties 
  Retrieving app2 of prod2 properties 
  Retrieving app2 of prod2 properties 
  Retrieving app2 of prod2 properties 
  Retrieving app3 of prod3 properties 
  Retrieving app3 of prod3 properties 
  Retrieving app3 of prod3 properties 
  </code></pre>
  <p>With the above code i can loop the &quot;app&quot; &amp; &quot;env&quot; list , Since i am looping based on list.size its looping 3*2 times and generating the result. But i need only 3 results</p>
  <p>Expected Output -</p>
  <pre><code>Retrieving app1 of prod1 properties 
  Retrieving app2 of prod2 properties 
  Retrieving app3 of prod3 properties 
  </code></pre>
  <p>Kindly help me on this code.</p>