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

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

XMLWordPrintable

      Problem

      == Inline Script Block
      Line: 73
      ----
      <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)+"/${buildAction.urlName}";
      				      }
      				    }                                                                                 
      				  }                                                                                   
      
      				  var options = {                                                                     
      				    title: 'Scenarios Assertions Trend',
      				    reverseCategories : true,                                              
      				    areaOpacity: 0.8,
      				    colors: ['yellow', 'red', 'lightgreen'],
      				    isStacked: true,                                                                                                                                               
      				    hAxis: {title: 'Build'},                                                          
      				    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: