这似乎是直截了当的要求,我需要为Jenkins提取驱动器,以便我可以构建剩余路径。 在JenkinsFile.xml中,我有以下
def drive = "${WORKSPACE}".substring(0, 1) // This saves drive as "C" as expected
echo "set MYVAR=${drive}" // this gets replaced and prints set MYVAR =C
withEnv([ ' MYVAR =${drive}']) { // However, this does expands to MYVAR =C as expected
bat ' set MYVAR =${drive}' // This gets execute as set MYVAR =${drive}
// Expected is set MYVAR =C
}
我也尝试过
withEnv([ ' MYVAR ="${drive}"']) { // However, this does expands to MYVAR =C as expected
withEnv([ ' MYVAR ="drive"']) { // However, this does expands to MYVAR =C as expected
我想念什么?
答案 0 :(得分:0)
修正是要更新脚本:
withEnv([ ' MYVAR =' + drive]) {
bat ' set MYVAR =' +drive
}