Active Choices Plugin

https://wiki.jenkins-ci.org/display/JENKINS/Active+Choices+Plugin

根据官方的说法由于Active Choices Plugin依赖Scriptler,所以在jenkins官方的更新中心不支持Active Choices Plugin

手动安装方法:

下载uno-choice1.5.3的hpi格式文件

https://repo.jenkins-ci.org/releases/org/biouno/uno-choice/

下载Scriptler 2.9的hpi格式文件

https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/scriptler/

系统管理-》管理插件-》高级-》上传插件

选择下载的hpi文件

安装Scriptler 和 uno-choice1.5.3

安装完成后重启jenkins,会有警告,可以忽略

使用方法

先创建一个自由风格的软件项目

所有实例来源于jenkins官方wiki

插件安装完以后参数化构建过程选项中会多出三个选项

Active Choices Parameter

可以被动态地渲染为标准的selection lists, check boxes and radio buttons

filters有效地帮助过滤变量的值

脚本

return['Sao Paulo', 'Rio de Janeiro', 'Parana', 'Acre']
return['error']

效果

补充:

默认选择

return['Sao Paulo', 'Rio de Janeiro', 'Parana:selected', 'Acre']

Active Choices Reactive Parameter

Active Choices Reactive Parameter拥有和Active Choices Parameter一样的特性,但是前者拥有Referenced parameters配置项,当任何一个Referenced parameters发生变化选项都会重新渲染。

Referenced parameters包含一个用逗号分隔的变量名,当任何一个变量的值发生变化时当前的选项跟着刷新

主要脚本:

if(States.equals("Sao Paulo")) {
    return ["Barretos", "Sao Paulo", "ltu"]
} else if (States.equals("Rio de Janeiro")) {
    return ["Rio de Janeiro", "Mangaratiba"]
} else if (States.equals("Parana")) {
    return ["Curitiba", "Ponta Grossa"]
} else if (States.equals("Acre")) {
    return ["Rio Branco", "Acrelandia"]
} else {
    return ["Unknown state"]
}

注:需要以上个实例为前置条件

Active Choices Reactive Reference Parameter

  • Input text box 直接渲染成文本
  • Numbered list 渲染成以数字标记的列表
  • Bullet items list 渲染成以点标记的列表
  • Formatted HTML 渲染成html
  • Formatted Hidden HTML 渲染成隐藏的html

脚本:

return['Champagne','Sauvignon Blanc','Grüner Veltliner','Pinot Grigio','Chardonnay','Off-Dry Riesling','Moscato dAsti','dry Rosé','Pinot Noir']

Input text box

Numbered list

Bullet items list

Formatted HTML

需要修改脚本

return '''<table border="0">
<tr>
  <td>Wine</td>
  <td>Price</td>
</tr>
<tr>
  <td>Champagne</td>
  <td>5</td>
</tr>
<tr>
  <td>Sauvignon Blanc</td>
  <td>6</td>
</tr>
<tr>
  <td>Grüner Veltliner</td>
  <td>7</td>
</tr>
<tr>
  <td>Pinot Grigio</td>
  <td>7</td>
</tr>
<tr>
  <td>Chardonnay</td>
  <td>6</td>
</tr>
<tr>
  <td>Off-Dry Riesling</td>
  <td>8</td>
</tr>
<tr>
  <td>Moscato dAsti</td>
  <td>6</td>
</tr>
<tr>
  <td>dry Rosé</td>
  <td>8</td>
</tr>
<tr>
  <td>Pinot Noir</td>
  <td>6</td>
</tr>
</table>'''

Formatted Hidden HTML

Active Choices Reactive Reference Parameter用法

主要脚本

return ['Champagne',
'Sauvignon Blanc',
'Grüner Veltliner',
'Pinot Grigio',
'Chardonnay',
'Off-Dry Riesling',
'Moscato dAsti',
'dry Rosé',
'Pinot Noir']
switch(WINE_MENU){
 case~/.*Champagne.*/:
    winerec='Champagne is perfect with anything salty'
    return "<b>${winerec}</b>"
 break
case ~/.*Sauvignon Blanc.*/:
    winerec='Sauvignon Blanc goes with tart dressings and sauces'
    return "<b>${winerec}</b>"
break
 case~/.*Grüner Veltliner.*/:
    winerec='Choose Grüner Veltliner when a dish has lots of fresh herbs'
    return "<b>${winerec}</b>"
 break
case~/.*Pinot Grigio.*/:
    winerec='Pinot Grigio pairs well with light fish dishes'
    return "<b>${winerec}</b>"
 break
case ~/.*Chardonnay.*/:
    winerec='Choose Chardonnay for fatty fish or fish in a rich sauce'
    return "<b>${winerec}</b>"
break
 case~/.*Off-Dry Riesling.*/:
    winerec='Off-Dry Riesling pairs with sweet & spicy dishes'
    return "<b>${winerec}</b>"
 break
 case~/.*Moscato dAsti.*/:
    winerec='Moscato dAsti loves fruit desserts'
    return "<b>${winerec}</b>"
 break
case ~/.*dry Rosé.*/:
    winerec='Pair a dry Rosé with rich, cheesy dishes'
    return "<b>${winerec}</b>"
break
 case~/.*Pinot Noir.*/:
    winerec='Pinot Noir is great for dishes with earthy flavors'
    return "<b>${winerec}</b>"
 break
}

results matching ""

    No results matching ""