Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-74605

[stoplightio-report] Extract inline script block in com/arkea/satd/stoplightio/StoplightReportProjectAction/floatingBox.jelly

XMLWordPrintable

      Problem

      == Inline Script Block
      Line: 13
      ----
      <script type="text/javascript">
      	    google.charts.load('current', {'packages':['corechart']});
      		google.charts.setOnLoadCallback(drawChart);
      
      		function drawChart() {                                                                
      		                                                                                      
      		  function selectHandler() {                                                          
      		    var selectedItem = chart.getSelection()[0];                                       
      		    if (selectedItem) {                                                               
      		      var topping = data.getValue(selectedItem.row, 0);                               
      	      	  if(topping!='') {                               
      		        window.location.href = topping.substring(1)+"/${tr.urlName}";
      		      }
      		    }                                                                                 
      		  }                                                                                   
      		                                                                                      
      		  var options = {                                                                     
      		    title: 'Scenarios Assertions Trend',                                              
      		    areaOpacity: 0.8,
      		    colors: ['yellow', 'red', 'lightgreen'],
      		    isStacked: true,                                                                                                                                               
      		    reverseCategories : true,
      		    chartArea: {left:30, right:80, top:20, bottom:35},                                                                 
      		    hAxis: {slantedText: true, slantedTextAngle:90},                                                                               
      		    vAxis: {                                                                          
      		      minValue: 0,                                                                    
      		      gridlines: {color : "#000"}
      		    }                                                                                 
      		  };                                                                                  
      		                                                                                      
      		  var data = new google.visualization.DataTable();                                    
      		  data.addColumn('string', 'Build');                                                  
      		  data.addColumn('number', 'No Test');                                                  
      		  data.addColumn('number', 'Failed');                                                 
      		  data.addColumn('number', 'Success');   
      		                                                                                      
      		  var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
      		  google.visualization.events.addListener(chart, 'select', selectHandler);
      
      		  <j:forEach var="buildAction" items="${projectCollections}">
                		data.addRow(['#${buildAction.buildNumber}', ${buildAction.noAssertionCount}, ${buildAction.failedAssertionsCount}, ${buildAction.succeededAssertionsCount}]);
                </j:forEach>
      
      		  <j:if test="${projectCollections.size() == 1}">
                		 data.addRow(['', 0, 0, 0]);
                </j:if>
      
      		  chart.draw(data, options);
                  
      	    }				
      	</script>
      ----
      

      Solution

      https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: