Created
May 7, 2019 23:10
-
-
Save imeanitworks/18989554090e15d6dd52c7af15201001 to your computer and use it in GitHub Desktop.
Groovy for loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/groovy | |
| pipeline { | |
| agent { label 'label' } | |
| define { | |
| def my_map = [:] //empty map | |
| def my_list //undefined shared variable | |
| } | |
| stages { | |
| stage('stage1') { | |
| steps { | |
| script { | |
| //If def can be anywhere in pipeline {}, drop script {} | |
| my_list = [1,2,3] | |
| } | |
| } | |
| } | |
| stage('stage2') { | |
| steps { | |
| script { | |
| for(int i=0; i<my_list.size();i++) { | |
| echo "Doing something with ${my_list[i]}" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment