简体   繁体   中英

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. 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"

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