Created
May 15, 2023 13:31
-
-
Save crl/68653a1aaaaeb61873559857e3d9264a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib.request | |
from urllib.parse import urlencode | |
import json | |
import sys | |
class JenkinsHttpPost: | |
def __init__(self,url): | |
self.url = url | |
def Post(self,postData): | |
test_data_urlencode = urllib.parse.urlencode(postData).encode('utf-8') | |
req = urllib.request.Request(url = self.url,data =test_data_urlencode) | |
try: | |
res_data = urllib.request.urlopen(req) | |
res = res_data.read() | |
except Exception as e: | |
print(e) | |
pass | |
def main(ip,jsonParam): | |
http_post = JenkinsHttpPost("http://{}:8080/generic-webhook-trigger/invoke".format(ip)) | |
data=json.loads(jsonParam) | |
#data["token"]="LuaTest" | |
http_post.Post(data) | |
if __name__ == '__main__': | |
main(sys.argv[1],sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jekins 设定任务 启动 JenkinsHttpPost.py 127.0.0.1 {"token":"dev_win"}