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

[global-yaml-properties] Extract inline script block in io/jenkins/plugins/globalyamlproperties/MultibranchYAMLJobProperty/config.jelly

XMLWordPrintable

      Problem

      == Inline Script Block
      Line: 11
      ----
      <script type="text/javascript">
                      document.addEventListener("DOMContentLoaded", function() {
                      var configForm = document.forms['config']; // This usually targets the job configuration form in Jenkins
                      var checkbox = document.querySelector('#enableReadOnly');
      
                      checkbox.addEventListener('change', function() {
                      var textarea = document.querySelector('textarea[name="yamlConfiguration"]');
                      var cm = textarea.nextSibling.CodeMirror;
                      var isReadOnly = cm.getOption('readOnly');
                      cm.setOption('readOnly', !isReadOnly);
                      });
      
                      if (configForm) {
                      configForm.addEventListener('submit', function(event) {
                      var errorDivs = document.querySelectorAll('div.error');
                      var hasVisibleErrors = Array.from(errorDivs).some(function(div) {
                          return div.textContent.trim().toLowerCase().includes("config");
                      });
      
                      if (hasVisibleErrors) {
                      event.preventDefault();
                      alert('Form validation failed. Please correct the errors and try again.');
                      }
                      });
                      }
                      });
                  </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: