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

Jenkins中基于build_type选择的条件参数实现插件咨询

Dynamic Parameter Visibility in Jenkins Based on Selection

Absolutely! You can totally pull off this dynamic parameter behavior in Jenkins with a couple of solid plugins. Here are the most reliable and widely-used options to make your build_type selection control the visibility of the snapshot name input:

This plugin is the go-to for dynamic, reactive parameters in Jenkins. Here's how to set it up:

  • First, install the Active Choices Plugin and its companion Active Choices Reactive Reference Parameter Plugin from Jenkins' plugin manager.
  • Create your initial build_type parameter as a Choice Parameter, with options Daily, Release, and Snapshot.
  • Add a new parameter of type Active Choices Reactive Reference Parameter:
    • Under "Referenced parameters", enter build_type (this links it to your selection).
    • Choose "Groovy Script" as the script type, then add this logic:
      if (build_type == 'Snapshot') {
          return ['Snapshot Name:']
      } else {
          return []
      }
      
    • Set the "Parameter Type" to Textbox — this will create an input field only when Snapshot is selected (since the script returns a label in that case, and nothing otherwise).

2. Extended Choice Parameter Plugin

Another great option that's straightforward for conditional visibility:

  • Install the Extended Choice Parameter Plugin from the plugin manager.
  • Create your build_type Choice Parameter as before.
  • Add a new Extended Choice Parameter:
    • Set the "Parameter Type" to Text Input (this will be your snapshot name field).
    • Scroll to the "Visible if" section, and enter the expression:
      ${build_type} == 'Snapshot'
      
    • Save your job configuration — now the snapshot name input will only appear when users select Snapshot from the build_type dropdown.

Quick Tips

  • Make sure you're running the latest versions of these plugins to avoid any compatibility issues.
  • Test your configuration by triggering a build and switching between the build_type options to confirm the snapshot field shows/hides as expected.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:17:29