0

My requirement is that I have written a bash script which monitors telnet on several ip(s) and ports. I have used the CSV which contains the input data and the script will read each row in the CSV and checks if the ip(s) can be telnet.

However I have requirement to jenkinize it, and I am wondering if there a way I can define my parameter in the Jenkins Job with different combination or values say for example:

PARAM_KEY : VAL_1

PARAM_KEY : VAL_2

PARAM_KEY : VAL_3

and so on thus I can use the PARAM_KEY in the script and the Jenkins job gets executed for all the parameters defined i.e. based on the number of PARAMETERS defined i.e. 3 in above case. Can any one guide me on this requirement.

Vikki Lohana
  • 39
  • 2
  • 10

1 Answers1

0

If you mean to run 1 job and iterate over the ips inside, you can parse the CSV file inside a pipeline or pass it as a parameter ( and then split it )

// example of pipeline code
node ('slave80') {

    csvString = "1.1.1.1,2.2.2.2,3.3.3.3" // can be sent as parameter

    def ips = csvString.split(',')
    ips.each { ip -> 

       sh """
           ./bash_script ${ip}
       """
    }
}
chenchuk
  • 5,324
  • 4
  • 34
  • 41