Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57501

cmakeBuild does not set environment variables in Windows when run in Pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Not A Defect
    • Component/s: cmakebuilder-plugin
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.164.3
      Cmake plugin version 2.6.1
      Jenkins slave running on windows machine as a service.
    • Similar Issues:

      Description

      Jenkins pipeline snippet: 

      def cmake_tasks() {
          def tasks=[:]
          def steps = [[withCmake: true]]
          def os = "windows"
          def config = "Debug"
          def generator = "Ninja"
      
      // ==== addidional env vars ====
          def vars="""
      LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0um\\x64;
      PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\binamd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64;C:\\Program Files (x86)\\Windows Kits\\10\\binx64;C:\\Program Files (x86)\\Windows Kits\\10\\binx86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\
       Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0libnvvp;g:\\Bin;
      """
      
      // another variant, also does not affect CMake
      //   vars = bat returnStdout: true, script: """
      //@call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
      //set
      //"""
      
      // third variant, also doesn't work
      //    bat """call c:\Path\to\Visual\Studio\vcvarsall.bat    
      //           set > build.props"""
      //    var = readFile("build.props")
      
           def cmakeArgs = "-DARG=VALUE"
           def cmake_inst = 'InSearchPath'
           steps.add([envVars: vars])
           cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"
           tasks["${os}"] = {
               node("${os}"){
                   stage("${os}/${config}") {
                       withEnv([vars]){
                           if (os == "windows"){
                               bat "set | sort"
                               println vars
                               println steps
                           }
         
                           cmakeBuild(buildDir: "build_${config}",
                                      buildType: config, 
                                      cleanBuild: true,
                                      cmakeArgs: cmakeArgs,
                                      generator: generator,
                                      installation: cmake_inst,
                                      sourceDir: ".", 
                                      steps: steps)
                      }
                  }
               }
            }
       
            return tasks
      }
       
      pipeline {
          agent none
          stages{
              stage('Configurte') {
                  steps{
                      script {
                          parallel cmake_tasks()
                      }
                  }
              }
          }
      }
       
      

       

       

      Snippet of CMakeLists.txt

      cmake_minimum_required(VERSION 3.12)
      message(STATUS "LIB value = $ENV{LIB}")
      message(STATUS "PATH value = $ENV{PATH}")
      

      Result:

      I see LIB and PATH in output of "set | sort " and both println's inside if(os == "windows") block.

      But output of cmake shows only default environment variables. LIB is unset, PATH is default

      LIB value = 
      PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
       
      

       

        Attachments

          Activity

          wl2776 Vladimir Eremeev created issue -
          wl2776 Vladimir Eremeev made changes -
          Field Original Value New Value
          Description Pipeline snippet

          {{def cmake_tasks() {
              def tasks=[:]
              def steps = [[withCmake: true]]

              def os = "windows"
              def config = "Debug"
              def generator = "Ninja"

              def vars="""
          LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\um\\x64;
          PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64\\;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
          """
              def cmakeArgs = "-DARG=VALUE"
              def cmake_inst = 'InSearchPath'

              steps.add([envVars: vars])
              cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"


              tasks["${os}"] = {
                  node("${os}"){
                        stage("${os}/Debug") {
                            withEnv([vars]){
                                          if (os == "windows") {
                                              bat "set | sort"
                                              println vars
                                              println steps
                                          }
                                          cmakeBuild(buildDir: "build_${config}",
                                                  buildType: config,
                                                  cleanBuild: true,
                                                  cmakeArgs: cmakeArgs,
                                                  generator: generator,
                                                  installation: cmake_inst,
                                                  sourceDir: ".",
                                                  steps: steps)
                            }
                        }
                  }
              }
              
              return tasks
          }

          pipeline {
              agent none
              stages{
                  stage('Configurte') {
                      steps {
                          parallel cmake_tasks()
                      }
                  }
              }
          }
          }}

          Snippet of CMakeLists.txt

          {{cmake_minimum_required(VERSION 3.12)

          message(STATUS "LIB value = $ENV{LIB}")
          message(STATUS "PATH value = $ENV{PATH}")
          }}

          Result:

          I see LIB and PATH in output of set and println.
          But output of cmake is

          {{LIB value =
          PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;}}

          Default values of environment variables.
          Pipeline snippet

          {{def cmake_tasks() {}}
          {{    def tasks=[:]}}
          {{    def steps = [[withCmake: true]]}}{{def os = "windows"}}
          {{    def config = "Debug"}}
          {{    def generator = "Ninja"}}{{def vars="""}}
          {{ LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\um\\x64;}}
          {{ PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:\\Program Files (x86)}}
          {{Windows Kits\\10\\bin\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64\\;C:}}
          {{Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;}}
          {{ """}}
          {{    def cmakeArgs = "-DARG=VALUE"}}
          {{    def cmake_inst = 'InSearchPath'}}{{steps.add([envVars: vars])}}
          {{    cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"}}

          {{    tasks["${os}"] = {}}
          {{        node("${os}"){}}
          {{            stage("${os}/${config}") {}}
          {{                withEnv([vars]){}}
          {{                    if (os == "windows")}}{{{}}

                                                       bat "set | sort"

                                                       println vars

                                                       println steps

          {{                    }}}

          {{                 cmakeBuild(buildDir: "build_${config}", }}
          {{                       buildType: config, }}
          {{                       cleanBuild: true, }}
          {{                       cmakeArgs: cmakeArgs, }}
          {{                       generator: generator, }}
          {{                       installation: cmake_inst, }}
          {{                       sourceDir: ".", }}
          {{                       steps: steps)}}
          {{               }}}
          {{           }}}
          {{        }}}
          {{     }}}

          {{     return tasks}}
          {{ }}}

           

          {{pipeline {}}
          {{    agent none}}
          {{    stages{}}
          {{        stage('Configurte') {}}
          {{            steps}}{{{}}

          {{                script {}}

          {{                    parallel cmake_tasks() }}

          {{                }}}

          {{            }}}
          {{        }}}

          {{     }}}
          {{ }}}

          Snippet of CMakeLists.txt

           

          {{cmake_minimum_required(VERSION 3.12)}}

          {{message(STATUS "LIB value = $ENV\{LIB}")}}
          {{ message(STATUS "PATH value = $ENV\{PATH}")}}

          Result:

          I see LIB and PATH in output of set and println.
           But output of cmake is

          {{LIB value = }}
          {{ PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;}}

           

          That is, default values of environment variables from system settings on the agent.
          wl2776 Vladimir Eremeev made changes -
          Description Pipeline snippet

          {{def cmake_tasks() {}}
          {{    def tasks=[:]}}
          {{    def steps = [[withCmake: true]]}}{{def os = "windows"}}
          {{    def config = "Debug"}}
          {{    def generator = "Ninja"}}{{def vars="""}}
          {{ LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\um\\x64;}}
          {{ PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:\\Program Files (x86)}}
          {{Windows Kits\\10\\bin\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64\\;C:}}
          {{Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;}}
          {{ """}}
          {{    def cmakeArgs = "-DARG=VALUE"}}
          {{    def cmake_inst = 'InSearchPath'}}{{steps.add([envVars: vars])}}
          {{    cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"}}

          {{    tasks["${os}"] = {}}
          {{        node("${os}"){}}
          {{            stage("${os}/${config}") {}}
          {{                withEnv([vars]){}}
          {{                    if (os == "windows")}}{{{}}

                                                       bat "set | sort"

                                                       println vars

                                                       println steps

          {{                    }}}

          {{                 cmakeBuild(buildDir: "build_${config}", }}
          {{                       buildType: config, }}
          {{                       cleanBuild: true, }}
          {{                       cmakeArgs: cmakeArgs, }}
          {{                       generator: generator, }}
          {{                       installation: cmake_inst, }}
          {{                       sourceDir: ".", }}
          {{                       steps: steps)}}
          {{               }}}
          {{           }}}
          {{        }}}
          {{     }}}

          {{     return tasks}}
          {{ }}}

           

          {{pipeline {}}
          {{    agent none}}
          {{    stages{}}
          {{        stage('Configurte') {}}
          {{            steps}}{{{}}

          {{                script {}}

          {{                    parallel cmake_tasks() }}

          {{                }}}

          {{            }}}
          {{        }}}

          {{     }}}
          {{ }}}

          Snippet of CMakeLists.txt

           

          {{cmake_minimum_required(VERSION 3.12)}}

          {{message(STATUS "LIB value = $ENV\{LIB}")}}
          {{ message(STATUS "PATH value = $ENV\{PATH}")}}

          Result:

          I see LIB and PATH in output of set and println.
           But output of cmake is

          {{LIB value = }}
          {{ PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;}}

           

          That is, default values of environment variables from system settings on the agent.
          Pipeline snippet

          {{def cmake_tasks() {}}
           {{    def tasks=[:]}}
           {{    def steps = [[withCmake: true]]}}{{def os = "windows"}}
           {{    def config = "Debug"}}
           {{    def generator = "Ninja"}}

          {{    def vars="""}}
           {{ LIB=C:
          Program Files (x86)
          Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:
          Program Files (x86)
          Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:
          Program Files (x86)
          Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:
          Program Files (x86)
          Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:
          Program Files (x86)
          Windows Kits\\10\\lib\\10.0.17763.0\\um
          x64;}}
           {{ PATH=C:
          Program Files (x86)\\MSBuild\\14.0\\bin\\amd64;C:
          Program Files (x86)
          Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:
          Program Files (x86)}}
           {{Windows Kits\\10\\bin\\x64;C:}}
          {{Program Files (x86)}}
          {{Windows Kits\\10\\bin\\x86;C:}}
          {{Program Files (x86)}}
          {{Microsoft SDKs\\Windows\\v10.0A\\bin}}
          {{NETFX 4.6.1 Tools\\x64}}
          {{;C:}}
           {{Program Files (x86)}}
          {{Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:}}
          {{Program Files}}
           {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:}}
          {{Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:}}
          {{Bin;}}
           \{{ """}}
           {{    def cmakeArgs = "-DARG=VALUE"}}
           {{    def cmake_inst = 'InSearchPath'}}{{steps.add([envVars: vars])}}
           {{    cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin}}
          {{ninja"}}

          {{    tasks["${os}"] = {}}
           {{        node("${os}"){}}
           {{            stage("${os}/${config}") {}}
           {{                withEnv([vars]){}}
           {{                    if (os == "windows")}}{\{{}}

                                                       bat "set | sort"

                                                       println vars

                                                       println steps

          {\{                    }}}

          {\{                 cmakeBuild(buildDir: "build_${config}", }}
           \{{                       buildType: config, }}
           \{{                       cleanBuild: true, }}
           \{{                       cmakeArgs: cmakeArgs, }}
           \{{                       generator: generator, }}
           \{{                       installation: cmake_inst, }}
           \{{                       sourceDir: ".", }}
           {{                       steps: steps)}}
           {{               }}}
           {{           }}}
           \{{        }}}
           {{     }}}

          {{     return tasks}}
           \{{ }}}

           

          {{pipeline {}}
           {{    agent none}}
           {{    stages{}}
           {{        stage('Configurte') {}}
           {{            steps}}{\{{}}

          {{                script {}}

          {\{                    parallel cmake_tasks() }}

          {\{                }}}

          {\{            }}}
           \{{        }}}

          {{     }}}
           \{{ }}}

          Snippet of CMakeLists.txt

           

          {{cmake_minimum_required(VERSION 3.12)}}

          {{message(STATUS "LIB value = $ENV\{LIB}")}}
           \{{ message(STATUS "PATH value = $ENV{PATH}")}}

          Result:

          I see LIB and PATH in output of set and println.
           But output of cmake is

          {\{LIB value = }}
           {{ PATH value = C:
          Program Files (x86)
          Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:
          Program Files}}
           {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:}}
          {{Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:}}
          {{Bin;}}

           

          That is, default values of environment variables from system settings on the agent.
          wl2776 Vladimir Eremeev made changes -
          Description Pipeline snippet

          {{def cmake_tasks() {}}
           {{    def tasks=[:]}}
           {{    def steps = [[withCmake: true]]}}{{def os = "windows"}}
           {{    def config = "Debug"}}
           {{    def generator = "Ninja"}}

          {{    def vars="""}}
           {{ LIB=C:
          Program Files (x86)
          Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:
          Program Files (x86)
          Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:
          Program Files (x86)
          Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:
          Program Files (x86)
          Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:
          Program Files (x86)
          Windows Kits\\10\\lib\\10.0.17763.0\\um
          x64;}}
           {{ PATH=C:
          Program Files (x86)\\MSBuild\\14.0\\bin\\amd64;C:
          Program Files (x86)
          Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64\\;C:
          Program Files (x86)}}
           {{Windows Kits\\10\\bin\\x64;C:}}
          {{Program Files (x86)}}
          {{Windows Kits\\10\\bin\\x86;C:}}
          {{Program Files (x86)}}
          {{Microsoft SDKs\\Windows\\v10.0A\\bin}}
          {{NETFX 4.6.1 Tools\\x64}}
          {{;C:}}
           {{Program Files (x86)}}
          {{Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:}}
          {{Program Files}}
           {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:}}
          {{Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:}}
          {{Bin;}}
           \{{ """}}
           {{    def cmakeArgs = "-DARG=VALUE"}}
           {{    def cmake_inst = 'InSearchPath'}}{{steps.add([envVars: vars])}}
           {{    cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin}}
          {{ninja"}}

          {{    tasks["${os}"] = {}}
           {{        node("${os}"){}}
           {{            stage("${os}/${config}") {}}
           {{                withEnv([vars]){}}
           {{                    if (os == "windows")}}{\{{}}

                                                       bat "set | sort"

                                                       println vars

                                                       println steps

          {\{                    }}}

          {\{                 cmakeBuild(buildDir: "build_${config}", }}
           \{{                       buildType: config, }}
           \{{                       cleanBuild: true, }}
           \{{                       cmakeArgs: cmakeArgs, }}
           \{{                       generator: generator, }}
           \{{                       installation: cmake_inst, }}
           \{{                       sourceDir: ".", }}
           {{                       steps: steps)}}
           {{               }}}
           {{           }}}
           \{{        }}}
           {{     }}}

          {{     return tasks}}
           \{{ }}}

           

          {{pipeline {}}
           {{    agent none}}
           {{    stages{}}
           {{        stage('Configurte') {}}
           {{            steps}}{\{{}}

          {{                script {}}

          {\{                    parallel cmake_tasks() }}

          {\{                }}}

          {\{            }}}
           \{{        }}}

          {{     }}}
           \{{ }}}

          Snippet of CMakeLists.txt

           

          {{cmake_minimum_required(VERSION 3.12)}}

          {{message(STATUS "LIB value = $ENV\{LIB}")}}
           \{{ message(STATUS "PATH value = $ENV{PATH}")}}

          Result:

          I see LIB and PATH in output of set and println.
           But output of cmake is

          {\{LIB value = }}
           {{ PATH value = C:
          Program Files (x86)
          Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:
          Program Files}}
           {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\bin;C:}}
          {{Program Files}}
          {{NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:}}
          {{Bin;}}

           

          That is, default values of environment variables from system settings on the agent.
          ipeline snippet

           
          {code:java}
          def cmake_tasks() {
              def tasks=[:]
              def steps = [[withCmake: true]]
              def os = "windows"
              def config = "Debug"
              def generator = "Ninja"

          // ==== addidional env vars ====
              def vars="""
          LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0um\\x64;
          PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\binamd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64;C:\\Program Files (x86)\\Windows Kits\\10\\binx64;C:\\Program Files (x86)\\Windows Kits\\10\\binx86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\
           Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0libnvvp;g:\\Bin;
          """

          // another variant, also does not affect CMake
          // vars = bat returnStdout: true, script: """
          //@call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
          //set
          //"""

               def cmakeArgs = "-DARG=VALUE"
               def cmake_inst = 'InSearchPath'
               steps.add([envVars: vars])
               cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"
               tasks["${os}"] = {
                   node("${os}"){
                       stage("${os}/${config}") {
                           withEnv([vars]){
                               if (os == "windows"){
                                   bat "set | sort"
                                   println vars
                                   println steps
                               }

                           cmakeBuild(buildDir: "build_${config}",
                                     buildType: config,
                                     cleanBuild: true,
                                     cmakeArgs: cmakeArgs,
                                     generator: generator,
                                     installation: cmake_inst,
                                     sourceDir: ".",
                                     steps: steps)
                          }
                      }
                  }
                }
           
                return tasks
          }
           
          pipeline {
              agent none
              stages{
                  stage('Configurte') {
                      steps{
                          script {
                              parallel cmake_tasks()
                        }
                      }
                  }
              }
          }
           
          {code}
           

           

          Snippet of CMakeLists.txt
          {code:java}
          cmake_minimum_required(VERSION 3.12)
          message(STATUS "LIB value = $ENV{LIB}")
          message(STATUS "PATH value = $ENV{PATH}")
          {code}
          Result:

          I see LIB and PATH in output of "set | sort " and both println's.

          But output of cmake shows only default environment variables. LIB is unset, PATH is default
          {code:java}
          LIB value =
          PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
           
          {code}
           

          That is, default values of environment variables from system settings on the agent.
          wl2776 Vladimir Eremeev made changes -
          Description ipeline snippet

           
          {code:java}
          def cmake_tasks() {
              def tasks=[:]
              def steps = [[withCmake: true]]
              def os = "windows"
              def config = "Debug"
              def generator = "Ninja"

          // ==== addidional env vars ====
              def vars="""
          LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0um\\x64;
          PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\binamd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64;C:\\Program Files (x86)\\Windows Kits\\10\\binx64;C:\\Program Files (x86)\\Windows Kits\\10\\binx86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\
           Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0libnvvp;g:\\Bin;
          """

          // another variant, also does not affect CMake
          // vars = bat returnStdout: true, script: """
          //@call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
          //set
          //"""

               def cmakeArgs = "-DARG=VALUE"
               def cmake_inst = 'InSearchPath'
               steps.add([envVars: vars])
               cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"
               tasks["${os}"] = {
                   node("${os}"){
                       stage("${os}/${config}") {
                           withEnv([vars]){
                               if (os == "windows"){
                                   bat "set | sort"
                                   println vars
                                   println steps
                               }

                           cmakeBuild(buildDir: "build_${config}",
                                     buildType: config,
                                     cleanBuild: true,
                                     cmakeArgs: cmakeArgs,
                                     generator: generator,
                                     installation: cmake_inst,
                                     sourceDir: ".",
                                     steps: steps)
                          }
                      }
                  }
                }
           
                return tasks
          }
           
          pipeline {
              agent none
              stages{
                  stage('Configurte') {
                      steps{
                          script {
                              parallel cmake_tasks()
                        }
                      }
                  }
              }
          }
           
          {code}
           

           

          Snippet of CMakeLists.txt
          {code:java}
          cmake_minimum_required(VERSION 3.12)
          message(STATUS "LIB value = $ENV{LIB}")
          message(STATUS "PATH value = $ENV{PATH}")
          {code}
          Result:

          I see LIB and PATH in output of "set | sort " and both println's.

          But output of cmake shows only default environment variables. LIB is unset, PATH is default
          {code:java}
          LIB value =
          PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
           
          {code}
           

          That is, default values of environment variables from system settings on the agent.
          ipeline snippet

           
          {code:java}
          def cmake_tasks() {
              def tasks=[:]
              def steps = [[withCmake: true]]
              def os = "windows"
              def config = "Debug"
              def generator = "Ninja"

          // ==== addidional env vars ====
              def vars="""
          LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0um\\x64;
          PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\binamd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64;C:\\Program Files (x86)\\Windows Kits\\10\\binx64;C:\\Program Files (x86)\\Windows Kits\\10\\binx86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\
           Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0libnvvp;g:\\Bin;
          """

          // another variant, also does not affect CMake
          // vars = bat returnStdout: true, script: """
          //@call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
          //set
          //"""

          // third variant, also doesn't work
          // bat """call c:\Path\to\Visual\Studio\vcvarsall.bat    
          // set > build.props"""
          // var = readFile("build.props")

               def cmakeArgs = "-DARG=VALUE"
               def cmake_inst = 'InSearchPath'
               steps.add([envVars: vars])
               cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"
               tasks["${os}"] = {
                   node("${os}"){
                       stage("${os}/${config}") {
                           withEnv([vars]){
                               if (os == "windows"){
                                   bat "set | sort"
                                   println vars
                                   println steps
                               }

                           cmakeBuild(buildDir: "build_${config}",
                                     buildType: config,
                                     cleanBuild: true,
                                     cmakeArgs: cmakeArgs,
                                     generator: generator,
                                     installation: cmake_inst,
                                     sourceDir: ".",
                                     steps: steps)
                          }
                      }
                  }
                }
           
                return tasks
          }
           
          pipeline {
              agent none
              stages{
                  stage('Configurte') {
                      steps{
                          script {
                              parallel cmake_tasks()
                        }
                      }
                  }
              }
          }
           
          {code}
           

           

          Snippet of CMakeLists.txt
          {code:java}
          cmake_minimum_required(VERSION 3.12)
          message(STATUS "LIB value = $ENV{LIB}")
          message(STATUS "PATH value = $ENV{PATH}")
          {code}
          Result:

          I see LIB and PATH in output of "set | sort " and both println's.

          But output of cmake shows only default environment variables. LIB is unset, PATH is default
          {code:java}
          LIB value =
          PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
           
          {code}
           
          wl2776 Vladimir Eremeev made changes -
          Description ipeline snippet

           
          {code:java}
          def cmake_tasks() {
              def tasks=[:]
              def steps = [[withCmake: true]]
              def os = "windows"
              def config = "Debug"
              def generator = "Ninja"

          // ==== addidional env vars ====
              def vars="""
          LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0um\\x64;
          PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\binamd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64;C:\\Program Files (x86)\\Windows Kits\\10\\binx64;C:\\Program Files (x86)\\Windows Kits\\10\\binx86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\
           Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0libnvvp;g:\\Bin;
          """

          // another variant, also does not affect CMake
          // vars = bat returnStdout: true, script: """
          //@call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
          //set
          //"""

          // third variant, also doesn't work
          // bat """call c:\Path\to\Visual\Studio\vcvarsall.bat    
          // set > build.props"""
          // var = readFile("build.props")

               def cmakeArgs = "-DARG=VALUE"
               def cmake_inst = 'InSearchPath'
               steps.add([envVars: vars])
               cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"
               tasks["${os}"] = {
                   node("${os}"){
                       stage("${os}/${config}") {
                           withEnv([vars]){
                               if (os == "windows"){
                                   bat "set | sort"
                                   println vars
                                   println steps
                               }

                           cmakeBuild(buildDir: "build_${config}",
                                     buildType: config,
                                     cleanBuild: true,
                                     cmakeArgs: cmakeArgs,
                                     generator: generator,
                                     installation: cmake_inst,
                                     sourceDir: ".",
                                     steps: steps)
                          }
                      }
                  }
                }
           
                return tasks
          }
           
          pipeline {
              agent none
              stages{
                  stage('Configurte') {
                      steps{
                          script {
                              parallel cmake_tasks()
                        }
                      }
                  }
              }
          }
           
          {code}
           

           

          Snippet of CMakeLists.txt
          {code:java}
          cmake_minimum_required(VERSION 3.12)
          message(STATUS "LIB value = $ENV{LIB}")
          message(STATUS "PATH value = $ENV{PATH}")
          {code}
          Result:

          I see LIB and PATH in output of "set | sort " and both println's.

          But output of cmake shows only default environment variables. LIB is unset, PATH is default
          {code:java}
          LIB value =
          PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
           
          {code}
           
          Jenkins pipeline snippet: 
          {code:java}
          def cmake_tasks() {
              def tasks=[:]
              def steps = [[withCmake: true]]
              def os = "windows"
              def config = "Debug"
              def generator = "Ninja"

          // ==== addidional env vars ====
              def vars="""
          LIB=C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17763.0um\\x64;
          PATH=C:\\Program Files (x86)\\MSBuild\\14.0\\binamd64;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Windows\\Microsoft.NET\\Framework64;C:\\Program Files (x86)\\Windows Kits\\10\\binx64;C:\\Program Files (x86)\\Windows Kits\\10\\binx86;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.1 Tools\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\
           Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0libnvvp;g:\\Bin;
          """

          // another variant, also does not affect CMake
          // vars = bat returnStdout: true, script: """
          //@call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
          //set
          //"""

          // third variant, also doesn't work
          // bat """call c:\Path\to\Visual\Studio\vcvarsall.bat    
          // set > build.props"""
          // var = readFile("build.props")

               def cmakeArgs = "-DARG=VALUE"
               def cmake_inst = 'InSearchPath'
               steps.add([envVars: vars])
               cmakeArgs = cmakeArgs + " -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_MAKE_PROGRAM=g:\\Bin\\ninja"
               tasks["${os}"] = {
                   node("${os}"){
                       stage("${os}/${config}") {
                           withEnv([vars]){
                               if (os == "windows"){
                                   bat "set | sort"
                                   println vars
                                   println steps
                               }
             
                           cmakeBuild(buildDir: "build_${config}",
                                       buildType: config,
                                     cleanBuild: true,
                                     cmakeArgs: cmakeArgs,
                                     generator: generator,
                                      installation: cmake_inst,
                                     sourceDir: ".",
                                          steps: steps)
                          }
                      }
                  }
                }
           
                return tasks
          }
           
          pipeline {
              agent none
              stages{
                  stage('Configurte') {
                      steps{
                          script {
                              parallel cmake_tasks()
                        }
                      }
                  }
              }
          }
           
          {code}
           

           

          Snippet of CMakeLists.txt
          {code:java}
          cmake_minimum_required(VERSION 3.12)
          message(STATUS "LIB value = $ENV{LIB}")
          message(STATUS "PATH value = $ENV{PATH}")
          {code}
          Result:

          I see LIB and PATH in output of "set | sort " and both println's inside if(os == "windows") block.

          But output of cmake shows only default environment variables. LIB is unset, PATH is default
          {code:java}
          LIB value =
          PATH value = C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\CMake\\bin;c:\\windows\\system32;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v7.0\\libnvvp;g:\\Bin;
           
          {code}
           
          wl2776 Vladimir Eremeev made changes -
          Attachment image-2019-05-22-10-36-53-131.png [ 47457 ]
          wl2776 Vladimir Eremeev made changes -
          Comment [ After careful studying of this discussion, as well as a web-page of snippet generator, it became clear for me that envVars, passed to cmakeBuild, has nothing to do with my issue.

          And the issue itself is invalid, since I've incorrectly passed arguments to cmake.

          Closing.

          Thanks for the help. ]
          wl2776 Vladimir Eremeev made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Fixed but Unreleased [ 10203 ]
          15knots Martin Weber made changes -
          Resolution Fixed [ 1 ] Not A Defect [ 7 ]
          Status Fixed but Unreleased [ 10203 ] Closed [ 6 ]

            People

            Assignee:
            15knots Martin Weber
            Reporter:
            wl2776 Vladimir Eremeev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: