[ https://issues.jenkins-ci.org/browse/JENKINS-12163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=161814#comment-161814 ]
Sylvain C. commented on JENKINS-12163: -------------------------------------- My solution : * Configure the slave with a disconnect type of Shutdown. * Create two new jobs : - SwitchOffLineNode (Change status of a node from Online to Offline) With a string parameter : name = NODE With a build step of windows batch type : {code:lang=html}cd %CURL_HOME% && curl \-k \-u USERNAME:USERPASSWORD \-d "offlineMessage=back_in_a_moment&json=%7B%22offlineMessage%22%3A+%22back_in_a_moment%22%7D&Submit=Mark+this+node+temporarily+offline" %JENKINS_URL%computer/%NODE%/toggleOffline > nul 2>&1{code} Replace USERNAME & USERPASSWORD - SwitchOnLineNode (Change status of a node from OffLine to Online) With a string parameter : name = NODE With a build step of windows batch type: {code:lang=html}cd %CURL_HOME% && curl \-k \-u USERNAME:USERPASSWORD \-d "Submit=This+node+is+back+online" %JENKINS_URL%computer/%NODE%/toggleOffline > nul 2>&1{code} Replace USERNAME & USERPASSWORD * Configure your job : First build step "windows batch command": {code:lang=html}set json="{\"parameter\": [{\"name\":\"NODE\", \"value\": \"%NODE_NAME%\"}], \"\": \"\"}" set url=%JENKINS_URL%/job/SwitchOfflineNode/build?delay=60sec cd %CURL_HOME% && curl -k -u USERNAME:USERPASSWORD -X POST %url% --data-urlencode json=%json%{code} Replace USERNAME & USERPASSWORD This build step switch offline the vmware to stop new build * On "Post build task" of your job (download post build plugin) Log Text = "Building" (to execute this task all the time like a "finally") Script {code:lang=html}set json="{\"parameter\": [{\"name\": \"NODE\", \"value\": \"%NODE_NAME%\"}], \"\": \"\"}" set url=%JENKINS_URL%/job/SwitchOnlineNode/build?delay=60sec cd %CURL_HOME% && curl -k -u USERNAME:USERPASSWORD -X POST %url% --data-urlencode json=%json% shutdown -s -f -t 30{code} Replace USERNAME & USERPASSWORD This script turns off the vmware and after switches online the vmware to execute new job. I use this solution to run "testcomplete" (graphic tests) jobs and I must run tests from a clean machine. > Cleaning VM before start next job in queue. > ------------------------------------------- > > Key: JENKINS-12163 > URL: https://issues.jenkins-ci.org/browse/JENKINS-12163 > Project: Jenkins > Issue Type: Bug > Components: vsphere-cloud > Reporter: Alexey Larsky > > Sylvain Chagnaud says: Hi, it's a very useful plugin. But I have a little > comment for a specific case. ... > Hi, it's a very useful plugin. But I have a little comment for a specific > case. In fact I want to revert to a snapshot before each job execution but if > several jobs try to run on the VMWare at the same time then the VMWare can't > revert to the snapshot. Do you have a solution, thank you ? > jswager - says: At the moment, I don't have a solution incorporated into the > plugin. But I... > At the moment, I don't have a solution incorporated into the plugin. But I'm > working on it. In the meantime, here's a workaround: > 1) Configure the slave with a disconnect type of Revert or Reset. > 2) In your test job, mark the slave temporarily offline. This will prevent > further jobs from targeting the slave. It would be something like this: > curl -d > "offlineMessage=back_in_a_moment&json=%7B%22offlineMessage%22%3A+%22back_in_a_moment%22%7D&Submit=Mark+this+node+temporarily+offline" > http://JENKINS_HOST/computer/NODE_TO_DISCONNECT/toggleOffline > 3) As a final step in your job, start a delayed shutdown of the VM. If it's > Windows, something like "shutdown /s /t -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira