霍格沃兹测试开发 ceshiren.com
# 获取Jenkins的版本
from jenkinsapi.jenkins import Jenkins
# Jenkins 服务
BASE_URL = "http://47.92.149.0:8080/"
# Jenkins 服务对应的用户名
USERNAME = "admin"
# Jenkins 服务对应的token
PASSWORD = "11b561c5b159bf72dffacb4aee5f330f1b"
jenkins_hogwarts = Jenkins(BASE_URL, USERNAME, PASSWORD)
print(jenkins_hogwarts.version)
# 获取Jenkins 的job 对象
job = jenkins_hogwarts.get_job("ck24")
# 构建hogwarts job, 传入的值必须是字典, key 对应 jenkins 设置的参数名
job.invoke(build_params={"task": "pytest_practice/test/cases/add/test_add_param.py"})
# 获取job 最后一次完成构建的编号
print(job.get_last_buildnumber())
跨域请求:同源判断
URL | 结果 | 原因 |
---|---|---|
http://store.company.com/dir2/other.html |
– | – |
http://store.company.com/dir/inner/another.html |
– | – |
https://store.company.com/secure.html |
– | – |
http://store.company.com:81/dir/etc.html |
– | – |
http://news.company.com/dir/other.html |
– | – |
URL | 结果 | 原因 |
---|---|---|
http://store.company.com/dir2/other.html |
同源 | 只有路径不同 |
http://store.company.com/dir/inner/another.html |
同源 | 只有路径不同 |
https://store.company.com/secure.html |
失败 | 协议不同 |
http://store.company.com:81/dir/etc.html |
失败 | 端口不同 ( http:// 默认端口是80) |
http://news.company.com/dir/other.html |
失败 | 主机不同 |
pip install -U flask-cors
from flask_cors import CORS
# 实例化一个flask服务
app = Flask(__name__)
# 解决跨域
CORS(app, supports_credentials=True)