jenkins实用插件1-Active Choices Plugin

前言:实际用法请参开官方用法 Active Choices Plugin,官方 wiki 讲解的非常详细,我这里也是从官方抽取自己喜欢的进行应用。

一、下载安装插件

用jenkins自带的插件管理下载又时会出现下载失败,你可以选择到官方下载插件down plugin,然后直接上传安装。

二、配置

1. 根据选择不同环境,而调出不同的机器

如图:

《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png
《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png

配置过程:参数化构建过程
–>Active Choices Parameter

《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png
《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png

return [
"dev"
,"qa",
"pl"
]

–> Active Choices Reactive Reference

《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png

dev=["sh-mengdian-girl-srv-dev-01"]
qa=["sh-mengdi-soa-srv-qa-01","sh-mengdn-soa-srv-qa-02","sh-mengdi-soa-srv-qa-03"]
pl= ["sh-median-soa-srv-pl-01","sh-mengdn-soa-srv-pl-02"]

if (env.equals("dev")) {
  return dev
} else if (env.equals("qa")) {
  return qa
} else if (env.equals("pl")) {
  return pl
} else {
  return ["Unknown hosts"]
}

保存后,构建可见效果

2. 根据git地址获得分支选项

如图:

《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png

配置:

《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png

git_url=git_url

branch= ['bash','-c',"git ls-remote -h  $git_url|grep -oP '(?<=refs/heads/).*'"].execute().text.readLines()

保存后,构建可见效果

3. 选择项目语言,调出对应的发布目录和脚本

《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png
《jenkins实用插件1-Active Choices Plugin》 Paste_Image.png

这个做法如图一,这里就不贴配置了。

    原文作者:撸大师
    原文地址: https://www.jianshu.com/p/3f54cf1674ce
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞