File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
plugin/src/main/resources/org/jenkinsci/plugins/workflow/cps/Snippetizer Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 1- function handlePrototype ( url , crumb ) {
1+ function handlePrototype ( url ) {
22 buildFormTree ( document . forms . config ) ;
33 // TODO JSON.stringify fails in some circumstances: https://gist.github.com/jglick/70ec4b15c1f628fdf2e9 due to Array.prototype.toJSON
44 // TODO simplify when Prototype.js is removed
@@ -7,13 +7,11 @@ function handlePrototype(url, crumb) {
77 return ; // just a separator
88 }
99
10- const headers = new Headers ( ) ;
11- headers . append ( "Content-Type" , "application/x-www-form-urlencoded" ) ;
12- headers . append ( "Jenkins-Crumb" , crumb ) ;
13-
1410 fetch ( url , {
1511 method : "POST" ,
16- headers : headers ,
12+ headers : crumb . wrap ( {
13+ "Content-Type" : "application/x-www-form-urlencoded"
14+ } ) ,
1715 body : "json=" + encodeURIComponent ( json ) ,
1816
1917 } )
@@ -37,9 +35,8 @@ document.addEventListener('DOMContentLoaded', () => {
3735
3836 const generatePipelineScript = document . getElementById ( "generatePipelineScript" ) ;
3937 const url = generatePipelineScript . getAttribute ( "data-url" ) ;
40- const crumb = generatePipelineScript . getAttribute ( "data-crumb" ) ;
4138 generatePipelineScript . onclick = ( _ ) => {
42- handlePrototype ( url , crumb ) ;
39+ handlePrototype ( url ) ;
4340 return false ;
4441 } ;
4542
Original file line number Diff line number Diff line change @@ -70,8 +70,7 @@ THE SOFTWARE.
7070 <f : block >
7171 <input type =" button" id =" generatePipelineScript" value =" ${%Generate Pipeline Script}"
7272 class =" submit-button primary"
73- data-url =" ${rootURL}/${it.GENERATE_URL}"
74- data-crumb =" ${h.getCrumb(request)}" />
73+ data-url =" ${rootURL}/${it.GENERATE_URL}" />
7574 <f : textarea id =" prototypeText" readonly =" true" style =" margin-top: 10px" />
7675 <l : copyButton text =" " clazz =" jenkins-hidden jenkins-!-margin-top-1" />
7776 <st : adjunct includes =" org.jenkinsci.plugins.workflow.cps.Snippetizer.handle-prototype" />
You can’t perform that action at this time.
0 commit comments