You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins:如何创建兼具Active Choice特性的可执行Groovy隐藏参数?

Solution: Hide an Active Choice Reactive Parameter While Retaining Its Script Capabilities

You don't need to switch to Jenkins' built-in Hidden Parameter (which lacks script support) — the Active Choice Reactive Parameter itself has a hidden display option that lets you keep your Groovy logic intact while hiding the parameter from the build page. Here's how to set it up:

Step-by-Step Configuration

  1. Open your Jenkins job's configuration page and navigate to the This project is parameterized section.
  2. Add a new Active Choice Reactive Parameter (not the Reference type).
  3. Set the parameter name to random_number, then paste your existing Groovy script into the Script field:
    import jenkins.model.Jenkins
    try{
        foo = 2
        return foo * foo
    } catch(e) {
        return e.message.tokenize()
    }
    
  4. The critical part: Under the Display Type dropdown in the parameter settings, select Hidden. This will prevent the parameter from appearing on the build parameter page, but it will still execute the Groovy script and generate its value in the background.
  5. Save your job configuration.

Using the Hidden Parameter

Your existing Active Choice Reference Reactive Parameter can still reference random_number exactly as before. For example, if you're generating HTML, you can use the parameter value with:

<p>The calculated value is: ${random_number}</p>

This approach keeps your code separated (no need to merge the logic into a single parameter) and maintains the script execution capability you need, while hiding the random_number parameter from end users.

内容的提问来源于stack exchange,提问作者JimShapedCoding

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:42:21