Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

cmake on Jenkins windows slave fails unless an interactive logon has been opened for the build user

We've recently set up Jenkins to start automation of builds for a Windows application and this uses Cmake for builds.

Jenkins slaves are created on demand and connected to the Jenkins master using WinRM launching the java remoting.jar and this seems to work fine.

However, when running the build it will fail the ABI detection and then be unable to compile its test app because of certificate or network password issues as below:

[build] $ c:jenkinsoolshudson.plugins.cmake.CmakeTool3.19.2incmake -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Release -A x64 -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 c:jenkinsworkspacepc-win10
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.
-- The C compiler identification is MSVC 19.28.29335.0
-- The CXX compiler identification is MSVC 19.28.29335.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Jenkins/tools/hudson.plugins.cmake.CmakeTool/3.19.2/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Jenkins/workspace/tpc-win10/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_8452c.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.8.2+25e4d540b for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.
    
      Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29335 for x64
      Copyright (C) Microsoft Corporation.  All rights reserved.
      cl /c /I"C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmp\" /I"Generated Files\" /IcmTC_8452c.dirDebug /Zi /W3 /WX- /diagnostics:column /sdl /MP /Od /Ob0 /Oi /Oy- /D WIN32 /D _WINDOWS /D UNICODE /D _UNICODE /D "CMAKE_INTDIR="Debug"" /D _UNICODE /D UNICODE /D WINAPI_FAMILY=WINAPI_FAMILY_APP /D __WRL_NO_DEFAULT_LIB__ /Gm- /MDd /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_8452c.dirDebug\" /Fd"cmTC_8452c.dirDebugvc142.pdb" /Gd /TC /FU"C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.28.29333libx86store
eferencesplatform.winmd" /analyze- /errorReport:queue "C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpestCCompiler.c"
      testCCompiler.c
    LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification [C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpcmTC_8452c.vcxproj]
      cmTC_8452c.vcxproj -> C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpDebugcmTC_8452c.exe
    C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0AppxPackageMicrosoft.AppXPackage.Targets(826,5): error : Certificate could not be opened: C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpcmTC_8452c.dirWindows_TemporaryKey.pfx. [C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpcmTC_8452c.vcxproj]
    C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0AppxPackageMicrosoft.AppXPackage.Targets(826,5): error : The specified network password is not correct. [C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpcmTC_8452c.vcxproj]
    C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVisualStudiov16.0AppxPackageMicrosoft.AppXPackage.Targets(826,5): error :  [C:Jenkinsworkspacepc-win10uildCMakeFilesCMakeTmpcmTC_8452c.vcxproj]

The same build will succeed if a user creates a separate RDP session to the windows host prior to executing the build:

[build] $ c:jenkinsoolshudson.plugins.cmake.CmakeTool3.19.2incmake -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Release -A x64 -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION=10.0 c:jenkinsworkspacepc-win10
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.
-- The C compiler identification is MSVC 19.28.29335.0
-- The CXX compiler identification is MSVC 19.28.29335.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Jenkins/workspace/tpc-win10/build

Initially I thought it may relate to Windows Defender but it seems to be as simple as needing the build user to have an interactive logon session open. Is there any way to emulate this for the process executing under WinRM without having to use RDP ?

question from:https://stackoverflow.com/questions/65601425/cmake-on-jenkins-windows-slave-fails-unless-an-interactive-logon-has-been-opened

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What version of Jenkins are you using, and is the Windows PC always logged in as a user, and then WinRM just launches the JAR? Or are you logging in as a user when you do the RDP?

I suspect Windows is running the slave agent as something different and you're running into permissions issues somewhere.

I can get Windows to work by using the Jenkins Agent Service on Startup.

  • Initiate first slave on the target PC
  • Install Jenkins Agent as a service on the admin account
  • Set service to start on reboot or when the service is not detected

Using this method, no RDP is necessary after I reboot.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...