Bash 向Jenkins中的shell脚本传递参数时替换错误

Bash 向Jenkins中的shell脚本传递参数时替换错误,bash,jenkins,groovy,Bash,Jenkins,Groovy,我试图通过设置shell脚本的stdOut来传递变量的值。 然而,在Jenkins的控制台中显示以下内容: [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Feature Segunda) [Pipeline] echo ${params.Segunda} [Pipeline] sh /var/jenkins_home/workspace/pruebaParametrizada@tmp/durable-71aead8

我试图通过设置shell脚本的stdOut来传递变量的值。 然而,在Jenkins的控制台中显示以下内容:

[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Feature Segunda)
[Pipeline] echo
${params.Segunda}
[Pipeline] sh
/var/jenkins_home/workspace/pruebaParametrizada@tmp/durable-71aead85/script.sh: 1: /var/jenkins_home/workspace/pruebaParametrizada@tmp/durable-71aead85/script.sh: Bad substitution
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] echo
Building finished successfully
我习惯于逃避引用,什么都不管用。我犯了一个严重的替换错误。我也尝试过不使用双引号

如果我在shell脚本参数中硬编码,它运行良好

pipeline {
    agent any
    parameters {
        string(defaultValue: "", description: '', name: 'One')
        string(defaultValue: "", description: '', name: 'Two')
    }
    stages {
        stage('Git Checkout') {
            steps {
                git credentialsId: 'personal-github', url: 'https:xxx'
            }
        }
        stage('Maven Compile') {
            steps {
                sh 'mvn clean compile'
            }
        }
        stage('Test One') {
            steps {
                //ERROR
                sh 'mvn test -Dcucumber.options="-t @${params.One}"'

                //This Works
                //sh 'mvn test -Dcucumber.options="-t @One"'
            }
        }      
    }
    post {
        always { 
            echo 'Building finished successfully'
            cucumber failedFeaturesNumber: -1, 
            failedScenariosNumber: -1, 
            failedStepsNumber: -1, 
            fileIncludePattern: '**/*.json', 
            jsonReportDirectory: 'target/cucumber/', 
            pendingStepsNumber: -1, 
            reportTitle: 'test features', 
            skippedStepsNumber: -1, 
            sortingMethod: 'ALPHABETICAL', 
            undefinedStepsNumber: -1
        }
    }
}

我找到了如下传递参数的方法`

sh”““mvn测试-Dcucumber.options='-t@${params.One}'”


感谢大家的响应。

变量在groovy中不会用单引号替换。@tkausl也可以用双引号替换
“mvn测试-Dcucumber.options=“-t@${params.One}”
请参阅:@MichaelKemmerzell感谢您的响应,我用双引号替换单冒号”和工作properly@JuanJoseEstrella很高兴听到这个!请随意投赞成票:P