Skip to content

Instantly share code, notes, and snippets.

@crl
Created May 15, 2023 13:31
Show Gist options
  • Save crl/68653a1aaaaeb61873559857e3d9264a to your computer and use it in GitHub Desktop.
Save crl/68653a1aaaaeb61873559857e3d9264a to your computer and use it in GitHub Desktop.
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])
@crl
Copy link
Author

crl commented May 15, 2023

jekins 设定任务 启动 JenkinsHttpPost.py 127.0.0.1 {"token":"dev_win"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment