【问题标题】:Use WORKSPACE drive in Jenkins Scripted Pipeline在 Jenkins Scripted Pipeline 中使用 WORKSPACE 驱动器
【发布时间】:2019-10-20 21:29:42
【问题描述】:

这似乎是直截了当的要求,我需要为 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

我错过了什么?

【问题讨论】:

    标签: jenkins jenkins-pipeline jenkins-groovy


    【解决方案1】:

    修复是更新脚本:

    withEnv([ ' MYVAR =' + drive]) {
            bat ' set MYVAR =' +drive 
        }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多