Search code examples
shelljenkinsjenkins-pipelinepipeline

How to pass the Variable values(VM Name) form text file to jenkins job so that it should perform the task in each VM


I have file consist of 10 VM name.I want to pass the each VM name as parameter for a jenkins job.so that my jenkins job should perform task specified in each machine.Can some one suggest how it can be done.How it can be done using pipeline script.

Example

File.txt consist below variables

VM1
VM2
VM3
..
vm10

and I want to pass the values to jenkins job name called "Setupenvironment"

Please suggest.


Solution

  • You can use the file parameter to pass a file to your job. For a declarative pipeline it looks like the following

    pipeline {
        parameters {
            file(name: 'FILE', description: 'Some file to upload')