5

I'm trying to use the Active Choice Reactive Reference Parameter plugin to have an "update button" in my parameterized Jenkins Job. It will call an API and get the values but for now I have a simple js that update a cell in the html table with a new value. I have tested the button and the javascript outside of Jenkins and it works fine. But when I add this to Jenkins and click the button it starts the Jenkins Job instead of updating the cell.

The two inputs enter image description here

enter image description here

Sample Groovy used:

upHTML=
'''
<!DOCTYPE html>
 
function update(){
  // Get all the rows of the table
  var rows = document.getElementById("tb1").rows;
  
  var r= "0"
  var c= "1"
  var col = rows[r].cells;
  
 // Target row with the target col (target cell) changed with the new value
  col[c].innerHTML = "New Value";

}
 
</script>
'''
return upHTML

The button is visible but it starts the Jenkins job as soon as it's clicked.

enter image description here

Geeshan
  • 506
  • 5
  • 13

1 Answers1

0

I bet the button is inside the same form as the "Build" button below thus when clicking it, it triggers the form submit. If the type is empty for button it is considered to be same as submit (See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button). Try to change the button HTML to:

<button type="button" class="button" onclick="update()">Update</button>
drodil
  • 2,292
  • 1
  • 22
  • 37