简体   繁体   中英

Is there way to pass parameter from Jenkins job to RobotFramework and/or python script? Can I do it with and without Jenkinsfile?

I want to run python or robot script in Jenkins with chosen parameter. I know how to make parameterized job, but I don't know how to pass chosen parameter to python or robot script. In example, I want to decide role (Aa, Bb, Cc or Dd) from Jenkins and run my test (robot or python file) with decided role. I can do this locally for robot file trough cmd prompt (which can be done trough Jenkins too since Jenkins uses cmd also) with:

robot -d results -v role:{role i want to use} -t testiwanttorun filewhichincludesthattest

So I want to replace that {role i want to use} with chosen parameter from Jenkins so I don't have to change configuration each time I want to change the role. Another example would be test which I want to run on different browsers depending on day, so I want to decide which browser I want use on this build.

I'm also eager to do this easier way without using commands like above. Hope I explained problem well enough.

It is just the same as when you pass a variable in a local command line interface.

Your choice parameter has a name, so use the name to pass it as an option in your command:

>robot -d results -v role:%ROLE% -t testiwanttorun filewhichincludesthattest

or bash:

$ robot -d results -v role:$ROLE -t testiwanttorun filewhichincludesthattest

Similarly with the browser choices.

This has also been shown on many other places, eg here: https://geekdudes.wordpress.com/2019/08/02/jenkins-run-shell-script-add-parameters-to-job/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM