|NO.Z.00369|——————————|CloudNative|——|KuberNetes&CI/CD.V07|——|Jenkins.v06|级联变量.v02|

一、Jenkins级联变量
### --- 创建级联变量pod

~~~     根据上一个变量不同的取值,而进行下一个变量进行取值。
~~~     Dashboard——>Enter an item name:pipeline-var-active——>Pipeline——>ok——>END
### --- 变量一:Active Choices Parameter:创建choices类型变量

~~~     # 变量一:
~~~     General——>This project is parameterized——>Active Choices Parameter——>Name:TEST_ENV——>Script:Groovy Script:return ['test1', 'test2', 'test3']——>
~~~     ——>Fallback Script——>Groovy Script:return ['error']——>Choice Type:Single Select:下拉选项——>Save——>
~~~     ——>Choice Type:Radio Buttons:单选——>Enable filters:过滤——>Save——>  
~~~     ——>Choice Type:Multi Select:多选——>Enable filters:过滤——>Save——>
~~~     ——>Choice Type:Check Boxes:多选——>Enable filters:过滤——>Save——> 
~~~     # 应用场景:

~~~     可以把这个Job做成多项目的Job ;同时发布很多模块,需要哪个应用可以勾选起来。
二、级联变量
### --- 变量二:Active Choices Reactive Reference Parameter:级联变量

~~~     General——>This project is parameterized——>Active Choices Parameter
~~~     ——>Name:TEST_ENV——>Script:Groovy Script:return ['test1:selected', 'test2', 'test3']
~~~     ——>Choice Type:Radio Buttons——>
~~~     test1:selected:表示test1会默认勾选上
### --- 变量二:

~~~     General——>This project is parameterized
~~~     ——>Active Choices Reactive  Parameter:参考另一个变量的值来取值
~~~     ——>Name:IMAGE_NAME——>Groovy Script:配置参数见下文代码
~~~     ——>Choice Type:Check Boxes
~~~     ——>Referenced parameters:TEST_ENV(级联哪一个变量的参数)——>Save——>
### --- 根据第一个不同的取值来打印第二个变量

if (TEST_ENV.equals('test1') ) {
    return ['test1-image1', 'test1-image2']
} else if (TEST_ENV.equals('test2') ) {
    return ['test2-image1', 'test2-image2']
} else if (TEST_ENV.equals('test3') ) {
    return ['no image']
}
三、pipeline语法
### --- pipeline语法

~~~     Jenkins pipeline语法:https://www.jenkins.io/doc/book/pipeline/syntax/
~~~     中文文档:https://www.jenkins.io/zh/doc/book/pipeline/syntax/
~~~     Jenkins Active Choice parameter:https://plugins.jenkins.io/uno-choice/

 

 

 

 

 

 

 

 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(77)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示