Running a Jenkins agent on a windows build machine can be unstable at restart or lack needed rights. In some cases you require a console session for interaction with policy restricted hardware. Or, the service wrapper limits JVM rights in a way that prevents compilers or test suites from running.

In these cases, PowerShell scheduled jobs module has a useful AtStartup trigger property as well as a RunElevated job option.

Tips:

  • Add ‘-noCertificateCheck’ java argument if you use a jenkins job to bootstrap agent chain of trust.
  • Change pipeline and java log to path or file name of your choice.
  • I have seen long windows update restarts interfere with the AtStartup trigger. Adding a contingency trigger will help in this case.
  • *“kick the can” and move the shared secret to a “secure” variable, file, or registry key. Please leave feedback if you have a better solution.

References: