Unix agents are launched via SSH, they can completely controlled by Jenkins master. If config their availability as Keep this agent online as much as possible, they can automatically connect to Jenkins master after restart.
But it is different for Windows agents, they are usually launched via java web start through JNLP protocol. This requires the Windows agents to actively open a JNLP file to establish a TCP connection to the Jenkins master. After Windows agents restart, they are offline and needed to be manually launched via java web start, which is not automatical enough.
Solution
Create the automatical connection script agent.bat in startup folder through Win -> All Programs -> Startup, this folder is always like C:\Users\robin.yue\AppData\Roaming\Microsoft\Windows\Start Menu\Programs.
The content of the script agent.bat:
Background
Unix agents are launched via SSH, they can completely controlled by Jenkins master. If config their availability as
Keep this agent online as much as possible
, they can automatically connect to Jenkins master after restart. But it is different for Windows agents, they are usually launched via java web start through JNLP protocol. This requires the Windows agents to actively open a JNLP file to establish a TCP connection to the Jenkins master. After Windows agents restart, they are offline and needed to be manually launched via java web start, which is not automatical enough.Solution
Create the automatical connection script
agent.bat
in startup folder throughWin -> All Programs -> Startup
, this folder is always likeC:\Users\robin.yue\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
. The content of the scriptagent.bat
:There are two ways to launch Windows agents:
The script
agent.bat
uses the second way, and is added into the startup to automatically run this command after restart.