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

Problem using MSBuild Tool name in multi-line batch file in Pipeline script

XMLWordPrintable

       
      In Jenkins->Global Tool Configuration->MSBUILD

      I Added a MSBUILD like below

      Name: MSBuildTool2017

      Path to MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe

      Variable ${tool 'MSBuildTool2017'} can be recognized in one-line batch script but not in the multi-line script, Why?

      Is there any way I can void the hardcoded MSBUILd Tool Path in the batch script of Jenkins pipeline script?

      def buildSource() { //${tool 'MSBuildTool2017'} is recognized.
       bat "\"${tool 'MSBuildTool2017'}\" ABC.sln /p:Configuration=Release /p:Platform=\"x64\" /t:rebuild"
      }

      def BuildABC() { //${tool 'MSBuildTool2017'} is not recognized.
       {

      bat label: '', script: '''@echo off

      set RETVAL=0

      echo Navigating to ABC folder
      cd %WORKSPACE%
      cd project

      echo Cleaning up bin folder
      REM del bin_x64
      *.exe /F /Q /S
      REM if NOT "%errorlevel%" == "0" set RETVAL=%errorlevel%

      echo Navigating to InstallActionsolution folder
      cd ABC

      echo Building ABC Binaries
      \"${tool 'MSBuildTool2017'}\" "ABC.sln" /p:Configuration=Release /p:Platform=\"x64\" /t:rebuild

      if NOT "%errorlevel%" == "0" set RETVAL=%errorlevel%

      exit %RETVAL%'''
      }

            marshall777 Lionel Cabasson
            liangming2003 Ming Liang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: