Launching Build from webpage stops working after upgrade from 1.9 to 2.3

14 views
Skip to first unread message

Robert Conde

unread,
Nov 14, 2016, 10:52:30 AM11/14/16
to Jenkins Users
Our builds generate a webpage which allows the end-user to more easily launch a new build based on the original build. Here's an example:

<head>
   
<title>Build Links</title>
   
<script>
     
function runNewBuild()
     
{
         xmlhttp
= new XMLHttpRequest();
         xmlhttp
.open("POST","/view/MyView/job/MyJob/buildWithParameters?Parm1=Razz&Parm2=Zazz");
         xmlhttp
.send()
     
}
   
</script>
</head>
<form onsubmit="return false;">
   
<button onClick="runNewBuild()">Run New Build</button>
</form>

The html file is stored in and accessed from the build workspace. E.g. the url is:


This worked fine in 1.9, but now fails after upgrading. I fixed some of the issues by setting:

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP","sandbox allow-forms allow-scripts;")

But I still get (using chrome inspector):

XMLHttpRequest cannot load https://jenkins.myCompany.com:8081/view/MyView/job/MyJob/buildWithParameters?Parm1=Razz&Parm2=Zazz. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.

Can anyone provide into any guidance? Googling tends to bring up stuff related to CORS, but unless I'm missing something...this should not be cross origin.

Thanks in advance,
Rob Conde
Reply all
Reply to author
Forward
0 new messages