Error while clicking on "build now" Please help me out on how to resolve this

Dear all,
Request you to help me out on how to resolve below error which shown in my console output.

Console output:

The following environment variables were removed by ‘Only Keep Specified Environment Variables’: BUILD_DISPLAY_NAME, BUILD_URL, CI, EXECUTOR_NUMBER, HUDSON_HOME, HUDSON_URL, JENKINS_URL, JOB_DISPLAY_URL, JOB_URL, NODE_LABELS, NODE_NAME, RUN_ARTIFACTS_DISPLAY_URL, RUN_CHANGES_DISPLAY_URL, RUN_DISPLAY_URL, RUN_TESTS_DISPLAY_URL, WORKSPACE, WORKSPACE_TMP

C:\ProgramData\Jenkins.jenkins\workspace\test>exit 0
Path To MSBuild.exe: msbuild.exe
Executing the command cmd.exe /C " chcp 1252 & msbuild.exe " && exit %%ERRORLEVEL%% from C:\ProgramData\Jenkins.jenkins\workspace\test
[testgit] $ cmd.exe /C " chcp 1252 & msbuild.exe " && exit %%ERRORLEVEL%%
Active code page: 1252
‘msbuild.exe’ is not recognized as an internal or external command,
operable program or batch file.
Build step ‘Build a Visual Studio project or solution using MSBuild’ marked build as failure
Finished: FAILURE

Thanks and regards

ensure that msbuild.exe is found in the path

Hi all,

thanks for your reply,

yes, pretty sure about the full file path under (Manage jenkins → Global Tool Configuration
→ Path to MSBuild “MSBuild.exe full file path” )

please help me to go for next step.

thanks and regards

The tool (msbuild.exe) must be accessible at that path on the agent where you are running the tool. The error message says that msbuild.exe is not on the path from that agent.

You could diagnose to confirm that by creating a temporary job that runs on the specific agent and runs the Windows batch command env. That will list all the environment variables as configured on that agent. You will see that one of the variables is PATH. You will see that PATH on the agent does not include the location of msbuild.exe.

Configure the agent so that the directory that contains msbuild.exe is listed in the PATH.