2017-07-21 71 views
0

說我Jenkinsfile是這樣的:詹金斯建基地唐參數值

pipeline { 
    agent any 
    parameters { 
     string(name: 'flag', defaultValue: 'stop', description: 'How should I greet the world?') 
    } 
    stages { 
    stage('Example') { 
      steps { 
       checkout scm 
       sh "echo \"Current Branch: ${env.BRANCH_NAME}.... \"" 
     sh 
      if [[ $(params.flag) == "run" ]]; then 
       echo "something" 
      fi 

這是失敗的。它不能讀取$(params.flag)裏面的步驟。我怎樣才能做到這一點??我正在使用multibranch pipeline作業類型。

回答

1

是這樣的(我認爲這主要是多線sh語法是關閉):

pipeline { 
    agent { label 'docker' } 
    parameters { 
     string(name: 'flag', defaultValue: 'stop', description: 'How should I greet the world?') 
    } 
    stages { 
     stage('Example') { 
      steps { 
       checkout scm 
       sh "echo \"Current Branch: ${env.BRANCH_NAME}.... \"" 
       sh """ 
        if [[ "${params.flag}" == "run" ]]; then 
         echo "something" 
        fi 
       """ 
      } 
     } 
    } 
}