'How to pass variable integer parameter from pipeline project to another project called in Jenkins

I have a) multiconfiguration project(named dummy_repo) that is parameterized, parameter name is value1. b)a pipeline project that builds the dummy_repo by calling 'build job' Below one works:

            steps{
                script {
                    def dummy_vars = [1, 2]
                    for (int i = 0; i < 2; ++i) {
                    async_test_number = i
                    echo "Printing inside loop async ${i}";
                    build job: 'dummy_repo', parameters: [string(name: 'value1', value: '1')]
                    }
                } 

What I am looking for ..is something like below.I need to run the same job with different parameters..preferably in a loop because I need to call the python script probably 20 times..

build job: 'dummy_repo', parameters: [string(name: 'value1', value: ${i})]

dummy_repo basically has a python script that takes arguments. I feed the parameter value1 to the python script. Something like,

python3 test_script --${value1}

Any suggestions on this please. Kindly throw some light if there are other better ways.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source