插件源码地址 https://github.com/jenkinsci/build-user-vars-plugin
问题背景
之前有写过 一篇 https://blog.csdn.net/mmh19891113/article/details/105747729
一直在使用 BuildUserVars 和 BuildNameDescriptionSetter 这2个插件,当然是在自由风格的job中使用的,
但是当我们转到 流水线 风格的job时候 发现 build-user-vars-plugin 不太好用了。
解决问题
通过翻阅资料,谷歌查询。
我们从这里 https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/ 查到一个关于 wrap的用法。
wrap: General Build Wrapper
This is a special step that allows to call build wrappers (also called "Environment Configuration" in freestyle or similar projects). Just select the wrapper to use from the dropdown list and configure it as needed. Everything inside the wrapper block is under its effect.
Note that only Pipeline-compatible wrappers will be shown in the list.
To use this step you need to specify a delegate class, e.g wrap([$class: 'AnsiColorBuildWrapper']).
通过介绍 简单的可以理解为 在自由风格 "