问题
Am trying to setup "AZure VM Agent" plugin in Azure.
Am done with all configurations and first time when i trigger a job, a slave on Azure gets created and it executes the job. But as soon as job execution completes, node goes into offline mode.
Now if I trigger another jenkins job, offline node is not coming online automatically and so jenkins job is stuck on "waiting for agent" or "agent is offline". After sometime, new agent comes and it takes its own time to get ready and all.
How can I configure slaves to go offline when no task and as soon as new task is available, use same slave node?
回答1:
Node goes offline only after 'n' number of minutes where 'n' is based on the configuration that you have set in your Jenkins dashboard (under Manager Jenkins -> Configure System -> Cloud section). By default it is set to '60' as shown in below screenshot. You would have to set it to '0' if you want the node to keep running. Also, make sure you tick the box for "Shutdown Only (Do Not Delete) After Retention Time".
I believe that it's better to manually not configure these slaves (i.e., by explicitly making it offline by either deallocating / shutting down the VM or by marking the node offline in Jenkins dashboard / etc.) because if we do so then as the node is supposed to be maintained by the Azure VM Agents Jenkins plugin as per the retention cycle but as it is disturbed manually so we may observe issues like "nodelabel is serviced by 1 node and 1 cloud. Permissions or other restrictions provided by plugins may prevent this job from running on those nodes", etc.
Hope these inputs helps! Cheers!
来源:https://stackoverflow.com/questions/61097428/jenkins-vm-azure-agent-node-goes-offline-after-work-and-unable-to-start-back