【问题标题】:Update Button with Active Choice Parameter in Jenkins在 Jenkins 中使用主动选择参数更新按钮
【发布时间】:2020-11-15 10:24:48
【问题描述】:

我正在尝试使用 Active Choice Reactive Reference Parameter 插件在我的参数化 Jenkins 作业中添加一个“更新按钮”。它将调用 API 并获取值,但现在我有一个简单的 js,它用新值更新 html 表中的单元格。我已经在 J​​enkins 之外测试了按钮和 javascript,它工作正常。但是当我将它添加到 Jenkins 并单击按钮时,它会启动 Jenkins 作业,而不是更新单元格。

两个输入

使用的示例 Groovy:

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

该按钮是可见的,但它会在单击后立即启动 Jenkins 作业。

【问题讨论】:

    标签: jenkins jenkins-plugins jenkins-groovy


    【解决方案1】:

    我敢打赌,该按钮与下面的“构建”按钮位于同一表单内,因此单击它时,它会触发表单提交。如果按钮的类型为空,则认为它与提交相同(参见:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button)。尝试将按钮 HTML 更改为:

    <button type="button" class="button" onclick="update()">Update</button>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-20
      • 1970-01-01
      相关资源
      最近更新 更多