1

のキー値のペアを使用した。これは、ジェンキンスのパラメータを持つことが、私の要件です:ジェンキンス

1. User selects 3 Values from Dropdown: DEV, QA, PROD 
2. Upon selection I need to return single value as parameter as like this: 
If DEV selected, return "Development http://dev.com 1" 
If QA selected, return "QA http://qa.com 2" 
If PROD selected, return "Production http://prod.com 3" 
3. Once the value is returned in a variable, I will use that variable value in next step of 'Windows batch command'. 

どこで、どのように/キー値を定義することができます。 Extended Choice Parameterプラグインを使用しようとしましたが、これを行う方法がわかりません。

答えて

0

マッピングは、Groovyスクリプトで実行できます。あなたはInputParamという名前のパラメータを持っている場合は、そのようなシステムのGroovyスクリプトでOutParamと呼ばれる新しいパラメータにマッピングすることができます

import hudson.model.* 
def parameterMap=[:] 
parameterMap.put('DEV','Development http://dev.com 1') 
parameterMap.put('QA','QA http://qa.com 2') 
parameterMap.put('PROD','Production http://prod.com 3') 

def buildMap = build.getBuildVariables() 
def inputValue=buildMap['InputParam'] 
buildMap['OutParam']=parameterMap[inputValue] 

setBuildParameters(buildMap) 

def setBuildParameters(map) { 
    def npl = new ArrayList<StringParameterValue>() 
    for (e in map) { 
     npl.add(new StringParameterValue(e.key.toString(), e.value.toString())) 
    } 
    def newPa = null 
    def oldPa = build.getAction(ParametersAction.class) 
    if (oldPa != null) { 
     build.actions.remove(oldPa) 
     newPa = oldPa.createUpdated(npl) 
    } else { 
     newPa = new ParametersAction(npl) 
    } 
    build.actions.add(newPa) 
} 

は、最初のビルドアクションとしてシステムのGroovyスクリプトを実行を選択します。 Windowsシェルの環境変数として出力パラメータにアクセスすることができます。 ECHO %OUTPARAM%

2

これは、アクティブな選択肢のプラグインを使用して達成することができ、あなたの参照のためのリンクや画像の下に検索

プラグインリファレンス:任意のプラグインなしでhttps://wiki.jenkins-ci.org/display/JENKINS/Active+Choices+Plugin

enter image description here

別の方法

シェルスクリプトを使用するとこれを実現できます

シェルスクリプトとしてビルドステップを追加し、値を返す次のスクリプトを追加します。 http://www.tutorialspoint.com/unix/if-elif-statement.htm

:名前のparamaterドロップダウンが$ url変数は、あなたの次のビルドに使用することができ、期待値が

シェルスクリプトリファレンスステップたであろう「ENV」

if [ $env == "DEV" ] 
then 
    url = "Development http://dev.com 1" 
elif [ $env == "QA" ] 
then 
    url = "QA http://qa.com 2" 
elif [ $env == "PROD" ] 
then 
    url = "Production http://prod.com 3" 
fi 

であると言うことができます