基本上,我正在我的计算机上运行Jenkins主服务器,并且我遵循当前流程:
我调用一个作业在我的从属节点计算机上执行批处理文件,该文件重新映像整个计算机。
如何设置Jenkins,以便在重新映像从属节点后,它会联系 Master ,然后根据已确定的配置执行应该执行的特定作业在执行第一份工作时?
理想的解决方案是让我简单地配置作业,以便在完成重新映像后在从机上执行特定的.exe文件。
示例:
Slave\ReImage.bat
<the slave node reimages itself here>
<it connects back to Jenkins via a batch file in the system startup (JNLP)>
Now what I want is for it to execute say:
program.exe file2use.csv
一旦机器完成重新映像,启动并在从属节点上启动JNLP代理,就可以在这台机器上运行。这个过程应该是自动化的,理想情况下,只需要在开始时设置工作并点击“构建”以完成整个过程。
Jenkins网站目前正在对某些页面进行返工,因此很难找到文档。如果有一个可靠的方法来使用管道插件,请告诉我。 对此有任何帮助或建议将非常感激。
谢谢。
答案 0 :(得分:0)
根据代理在运行批处理脚本后脱机的速度,您可能会使用Pipeline执行类似的操作:
// Run tasks on the target agent
node('agent') {
// Get the scripts
git 'https://example.com/reimage-scripts.git'
// Re-image this machine
bat 'reimage'
}
// Give the agent a chance to go offline;
// this doesn't need an agent to run on
sleep 30
// Run more tasks on the agent; this will block until it's online again
node('agent') {
// Get the scripts
git 'https://example.com/reimage-scripts.git'
// Run the setup program
bat 'program.exe file2use.csv'
}
如果你想要比#34更聪明的东西,可以稍微睡一觉,你可能会用以下内容代替:
// Watch from another machine until the agent goes offline
node('master') {
bat 'ping-agent-until-it-goes-offline'
}