Powershell脚本看不到Jenkins管道传递的变量

时间:2020-07-16 13:58:03

标签: powershell jenkins jenkins-pipeline parameter-passing

在我的Powershell脚本中,我有一个变量[switch]$showCurrnet = $false,它在代码中的用法是:

if($showCurrnet)
{
    //some code here
}

如果我使用此./MyScript.ps1 -showCurrent在Powershell中运行此脚本,则一切正常-脚本将showCurrent标志设置为True,并进入if statemant。

但是当我像这样从Jenkins管道运行此脚本时:

stage('Run this script') {
            steps {
                script{
                echo "Some echo"
                bat 'powershell Path_to_my_script/MyScript.ps1 -showCurrent'
              } }
        }

脚本看不到showCurrent,也没有进入if陈述。

我应该怎么做才能将该变量从Jenkins正确传递给我的脚本?

0 个答案:

没有答案
相关问题