在Windows Slave的Jenkins管道中的bat步骤中访问Groovy变量

时间:2018-10-17 20:25:40

标签: jenkins groovy jenkins-pipeline

stage('Test Application'){
        agent { label 'windows' }
        steps{
                script{
                        def appName = "${params.ApplicationName}"
        println appName
        def appName1 = "\"Projects/$appName\""
        println appName1

        bat '''cd cognizant-intelligent-test-scripter-1.1-setup
                               run.bat -run -project_location appName1 -scenario "Scenario1" -testcase "TC2" -browser "IE" -standalone_report'''

              }
            }

我想在groovy节的蝙蝠节中使用变量 appName1 的实际值,但是在没有得到替换的情况下使用变量值。.请在管道的上一级执行时查看命令输出:

 Running on windows in C:\Jenkins\workspace\CI_Pipeline
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Billing
[Pipeline] echo
"Projects/Billing"
[Pipeline] bat
[CI_Pipeline] Running batch script

C:\Jenkins\workspace\CI_Pipeline>cd cognizant-intelligent-test-scripter-1.1-setup 

C:\Jenkins\workspace\CI_Pipeline\cognizant-intelligent-test-scripter-1.1-setup>run.bat -run -project_location appName1 -scenario "Scenario1" -testcase "TC2" -browser "IE" -standalone_report

0 个答案:

没有答案