Jenkins:如何创建兼具Active Choice特性的可执行Groovy隐藏参数?
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
- Open your Jenkins job's configuration page and navigate to the This project is parameterized section.
- Add a new Active Choice Reactive Parameter (not the Reference type).
- 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() } - 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.
- 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

