Jenkins Active Choice Parameter插件


 

Active Choice plug-in會生成三種參數類型:

    1,Active Choices Parameter(主動選擇參數) Active Choices參數使用Groovy腳本或Scriptler目錄中的腳本動態生成構建參數的值選項列表。 2,Active Choices Reactive Parameter(主動選擇反應參數) 根據主動選擇參數的選項而提供不同的對應值或者列表選項。 3,Active Choices Reactive Reference Parameter(主動選擇反應參考參數) 根據主動選擇參數的選項而展示對應參數的一些說明,與第二項的區別在於本參數只作為說明信息,而不能夠作為變量往下傳遞。

 


  1.  

     

    Development=["development-1","development-2"]
    Production=["production-1","production-2","production-3"]
    UAT=["uat-1","uat-2"]
     if (Environment.equals("Development")) {
     return Development } else if (Environment.equals("Production")) {
     return Production } else if (Environment.equals("UAT")) {
     return UAT } else { return ["Unknown hosts"]
    }

     

  2. 動態列出目錄下的文件

     

     

     


  3.  

     

     

     

    return[ 'Sao Paulo', 'Sao Paulo-1:selected', 'Rio de Janeiro', 'Rio de Janeiro-1:disabled', 'Parana', 'Acre' ]
    if (States.equals("Sao Paulo")) {
      return ["Barretos", "Sao Paulo", "Itu"]
    } 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"]
    }
    switch(States){ case~/.*Sao Paulo.*/: winerec='Champagne is perfect with anything salty' return '<img src="https://part-item-images.oss-cn-shanghai.aliyuncs.com/001/055/979.jpg">' break case ~/.*Parana.*/: winerec='Sauvignon Blanc goes with tart dressings and sauces' return "<b>${winerec}</b>"
    break case~/.*Acre.*/: winerec='Choose Grüner Veltliner when a dish has lots of fresh herbs' return "<b>${winerec}</b>"
     break case~/.*Rio de Janeiro.*/: winerec='Pinot Grigio pairs well with light fish dishes' return '<img src="https://part-item-images.oss-cn-shanghai.aliyuncs.com/001/055/910.jpg">' 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 }

    https://blog.csdn.net/tobealistenner/article/details/109071609

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM