1

I am trying to execute a .vbs file by passing parameters in Jenkins pipeline script.
After clicking "Build with Parameters" I entered all input parameters but below script is not passing the values I entered.
The '${param.XXX}' seems to be not working. The values passed to vbs are always ${params.DELIVERY} ${params.SOURCE_ENV} ${params.TERGET_ENV} ${params.GENREPORT}
but ideally arguments passed to vbs should be equal to the data entered before triggering pipeline. Can anyone please help me?

#!/usr/bin/env groovy
pipeline {
    agent any
    parameters {
        string(defaultValue: '', description: 'Delivery name', name: 'DELIVERY')
        choice(choices:'DEV1\nDEV2\nDEV3',description: 'Select Source environment',  name: 'SOURCE_ENV')
        choice(choices:'TEST1\nTEST2\nTEST3',description: 'Select target environment',  name: 'TERGET_ENV')
        choice(choices:'Yes\nNo',description: 'Generate Report?',  name: 'GENREPORT')

    }

stages {
    stage("Start Batch") {
    steps {
    bat '''
        echo '${params.DELIVERY}'
        echo '${params.SOURCE_ENV}'
        echo '${params.TERGET_ENV}'
        echo '${params.GENREPORT}'
        cd "C:\\Users\\DELIVERY_BATCH\\src"
        cscript.exe DELEXCEBATCH.vbs "C:\\Users\\Documents\\BatchFiles" ${params.DELIVERY} ${params.SOURCE_ENV} ${params.TERGET_ENV} ${params.GENREPORT}
        EXIT /B 0
    '''
    }
    }
    stage("Create Summary Excel sheet") {
    steps {
    bat '''
    echo 'Batch Execution is successful'
    '''
    } 
    }   
}
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
rdhar86
  • 51
  • 5
  • 1
    In groovy you can pass params into double quoted string "${params.SOURCE_ENV}" – Evgeny Smirnov Jan 28 '18 at 17:25
  • Possible duplicate of [What's the difference of strings within single or double quotes in groovy?](https://stackoverflow.com/questions/6761498/whats-the-difference-of-strings-within-single-or-double-quotes-in-groovy) – mkobit Jan 28 '18 at 19:46

1 Answers1

4

This:

bat '''

Should be:

bat """

Because variables are only evaluated when double quotes are used.

Tomas Bjerre
  • 3,270
  • 22
  • 27