[英]Pass Jenkins Parameter to python script in a Build
I have a jenkins job with parameter "github_username" which is being passed to a python script with below line.I used a string parameter but the script is runnig against each letter of the username instead runnig against the username as a single word.我有一个带有参数“github_username”的 jenkins 作业,该作业正在通过下面的行传递给 python 脚本。我使用了一个字符串参数,但脚本是针对用户名的每个字母运行的,而不是针对用户名作为一个单词运行。 is there a better to this?有更好的吗?
users = os.environ.get("github_username")
import os
## Reading all members from file
## with open('users.txt') as file:
## users = file.read().splitlines()
## users = os.environ.get('github_username')
users = os.environ['github_username']
Try this:尝试这个:
import os
users = os.environ['github_username']
And in your pipeline, use something like this:在你的管道中,使用这样的东西:
sh "python3 my-little-python3.py"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.