繁体   English   中英

有没有办法将参数从 Jenkins 作业传递到 RobotFramework 和/或 python 脚本? 我可以在有和没有 Jenkinsfile 的情况下做到这一点吗?

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

我想使用所选参数在 Jenkins 中运行 python 或机器人脚本。 我知道如何进行参数化作业,但我不知道如何将所选参数传递给 python 或机器人脚本。 例如,我想从 Jenkins 中确定角色(Aa、Bb、Cc 或 Dd)并以确定的角色运行我的测试(机器人或 python 文件)。 我可以通过 cmd 提示在本地为机器人文件执行此操作(也可以通过 Jenkins 完成,因为 Jenkins 也使用 ZDFFF04A7661A55FDACA2:1)

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

所以我想用从 Jenkins 中选择的参数替换那个 {role i want to use},这样我就不必每次想要更改角色时都更改配置。 另一个例子是测试我想根据日期在不同的浏览器上运行,所以我想决定我想在这个构建中使用哪个浏览器。

我也渴望在不使用上述命令的情况下以更简单的方式进行操作。 希望我能很好地解释问题。

这与在本地命令行界面中传递变量时相同。

您的选择参数有一个名称,因此请使用该名称在您的命令中将其作为选项传递:

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

或 bash:

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

与浏览器选择类似。

这也显示在许多其他地方,例如这里: https://geekdudes.wordpress.com/2019/08/02/jenkins-run-shell-script-add-parameters-to-job/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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