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

groovy: adding html button to job description is ignoring onclick javascript cmds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • core
    • None
    • jenkins master installed on linux dist.
      version: 1.645
      client browsers: firefox/chrome

      Hi jenkins experts,

      I used the following groovy code to add a button with some javascript ajax actions for triggering other jobs.

      job.builds
      .findAll { build -> build.number == buildNumber }
      .each { build ->
          build.setDescription("""
              <button
                  type='button'
                  onclick='javascript:
                      console.log("OnClick Action triggered!");
                      var another_job = function() {
                            new Ajax.Request("http://jenkins.alalala/hudson/job/AA_dummy_job_AUTO/build", {
                            method: "post",
                            parameters: {json: Object.toJSON({parameter: [{name: "SOME_JOB_PARA", value: "MY_VALUE"}]})}
                        });
                      };
      
                      another_job();
                      location.reload();'>Do Something!</button>""")
      }
      

      The button is visible in the description after the build has finished, but the onClick action is simply not created. Filtered out?

      Do i have to install additional jenkins plugins to allow javascript or ajax actions? Thanks for your support!

            Unassigned Unassigned
            dodger82 simon werling
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: