Here is a chunk of code I have in a pipeline:
def doBuild(folder, script, scriptArguments = '') {
bat '''cd folder
call script scriptArgument'''
}
So basically, it is a windows command saying: move to this directory, and call this script.
Of course, during execution, the command will be executed as 'cd folder' and will fail.
How can I make sure the 'folder' is replaced by the value passed in argument ?
Edit:
Following the suggestion of Vitalii, I tried the following code:
/* Environment Properties */
repository_name = 'toto'
extra_repository_branch = 'master'
branch_to_build = "${env.BRANCH_NAME}"
version = "${branch_to_build}_v1.5.4.${env.BUILD_NUMBER}"
/* Methods definitions properties */
def doTag() {
dir(repository_name) {
String tagCommand = """git tag -m "Release tag ${env.BUILD_URL}" ${version}"""
String pushCommand = "git push --tags origin ${branch_to_build}"
bat '''
call $tagCommand
call $pushCommand'''
}
}
Here is the output:
C:\Jenkins\toto>call $tagCommand '$tagCommand' is not recognized as an internal or external command, operable program or batch file.
C:\Jenkins\toto>call $pushCommand '$pushCommand' is not recognized as an internal or external command, operable program or batch file.
Thanks very much for your time