bat command failing with 'cmd' is not recognized as an internal or external command

1,634 views
Skip to first unread message

Tom Gwozdz

unread,
Oct 6, 2016, 2:59:13 PM10/6/16
to Jenkins Users
I have a pipeline script (pasted below).  When I run it as-is, the windows branch "bat" step fails with the error "'cmd' is not recognized as an internal or external command". But if I comment out the macos and emscripten branches, the windows branch works just fine. Am I doing something wrong?

#!groovy


stage "check out"

node {

    deleteDir()
    checkout scm

    stash includes: "**", name: "source"

}


stage "build"

parallel (

    "windows": {

        node ("windows && visualstudio") {
            deleteDir()

            unstash "source"

            def workspace = pwd()

            dir ("build") {
                bat "cmake .. -G \"Visual Studio 14 2015 Win64\" -DCMAKE_INSTALL_PREFIX=${workspace}\\install\\windows"
                bat "cmake --build . --target ALL_BUILD --config Release"
            }

            stash includes: "install/**", name: "windowsBinaries"
        }

    },

    "macos": {

        node ("macos && xcode") {
            deleteDir()
            env.PATH = "/usr/local/bin:${env.PATH}"

            unstash "source"

            dir("build") {
                sh "cmake .. -DCMAKE_INSTALL_PREFIX=../install/macos"
                sh "make"
            }

            stash includes: "install/**", name: "macosBinaries"
        }

    },

    "emscripten": {

        node ("emscripten") {
            deleteDir()
            env.PATH = "/usr/local/bin:${env.PATH}"

            unstash "source"

            dir ("build") {
                sh "cmake .. -DCMAKE_INSTALL_PREFIX=../install/emscripten -DCMAKE_TOOLCHAIN_FILE=~/emsdk_portable/emscripten/1.35.0/cmake/Modules/Platform/Emscripten.cmake"
                sh "make"
            }

            stash includes: "install/**", name: "emscriptenBinaries"
        }

    }

)


stage "package"

node {
    deleteDir()

    unstash "macosBinaries"
    zip zipFile: "thorcc-external-macos.zip", archive: true, dir: "install/macos"

    unstash "emscriptenBinaries"
    zip zipFile: "thorcc-external-emscripten.zip", archive: true, dir: "install/emscripten"

    unstash "windowsBinaries"
    zip zipFile: "thorcc-external-windows.zip", archive: true, dir: "install/windows"

    try {
        build job: "ThorCC/" + BRANCH_NAME, wait: false
    } catch (error) {
        echo "Skipped building downstream project because branch " + BRANCH_NAME + " doesn't exist."
    }

}



Tom Gwozdz

unread,
Oct 6, 2016, 3:19:50 PM10/6/16
to Jenkins Users
And of course after struggling with it for a long time, I find the problem just after I ask for help.  It turns out setting env.PATH affects all nodes, not just the local node, which was then affecting the PATH on the windows build.  I changed those to withEnv calls instead and all is well.

Thanks!

Reply all
Reply to author
Forward
0 new messages