jenkins v2.229 版本,無法勾選 “跨站請求偽造保護”

藍藍發表於2020-04-08

如題:

就是在Manage jenkins -> Configure Global Security -> 跨站請求偽造保護 這個沒有勾選框啊,咋辦??

無法勾選這會導致,使用jenkinsapi呼叫,build_job時會報錯

jenkinsapi.custom_exceptions.JenkinsAPIException: Operation failed. url=http://ci.test.com/jenkins/job/test_job_name/build, data={'json': '{"parameter": [], "statusCode": "303", "redirectTo": "."}'}, headers={'Content-Type': 'application/x-www-form-urlencoded', 'Jenkins-Crumb': '42a52abd17c6bf259171d23c5ab84018cfd024f1d319fe0d249c2955680382d5'}, status=403, text=b'<!doctype html><html lang="en"><head><title>HTTP Status 403 \xe2\x80\x93 Forbidden</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 403 \xe2\x80\x93 Forbidden</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> No valid crumb was included in the request</p><p><b>Description</b> The server understood the request but refuses to authorize it.</p><hr class="line" /><h3>Apache Tomcat/8.5.34</h3></body></html>'

觸發構建指令碼:

def build_job(job_name = "test_job_name"):
from jenkinsapi.utils.crumb_requester import CrumbRequester
j = Jenkins(URL, username=JENKINS_USER, password=JENKINS_PASSWORD, requester=CrumbRequester(username=JENKINS_USER, password=JENKINS_PASSWORD, baseurl=URL))
# j = Jenkins(URL, username=JENKINS_USER, password=JENKINS_PASSWORD)
# j[job_name].invoke()
print(j.build_job(job_name))
return True

我另外一個jenkins v2.150.3是可以的,有勾選框

有哪位大佬知道腫麼回事麼?

相關文章