Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Plugin Information

View scripted Cloud on the plugin site for more information.


Add script based slave VM management to Jenkins to use virtual machines as slaves

Description

This plugin adds to the Jenkins CI a way to control virtual machines through scripts. It takes two scripts: one for starting

NOTE: A great deal of thanks to the authors of the vshpere cloud Plugin; their
code was heavily copied to make this plugin.

Configuration

scripted Cloud Configuration

The first step is to add a new "Cloud" in the Jenkins "Configure System" menu based on "scripted Cloud". Enter its description, start and stop scripts.

Start script: This is called while launching slave of this cloud. Its expected that this script ensures that VM is up and running. Configure the slave configuration on VM such that it connects to master automatically on start. For this setup slave by options: Java web start or add a startup script on slave to connect to master.

Stop script: This is called after the job has finished after all post-build steps.

You can pass parameters to these scripts in the text box, e.g. my_startup_script param1 param2 ...

Various environment variables are passed to these scripts as mentioned next section.

scripted Slave Configuration

Select "Slave virtual computer running under scripted Cloud" while creating node. Following screen shot shows node configuration.


Here is description of important inputs. The test enclosed brackets after input name is the environment variable exposed to selected scripted-cloud start/stop scripts.

  • scripted Cloud Instance: This is the name of the scripted Cloud that you want to use
  • Virtual Machine Name     (SCVM_NAME)               : The name of the virtual machine as it appears in scripted.
  • Virtual Machine Platform (SCVM_PLATFORM)       : The name of the virtual machine as it appears in scripted.
  • Virtual Machine Group    (SCVM_GROUP)             : The name of the virtual machine as it appears in scripted.
  • Snapshot Name             (SCVM_SNAPNAME)      : the name of the snapshot to use. This is optional.
  • Force VM Launch           (SCVM_FORCESTART)  : Launches the virtual machine when necessary.
  • Extra Params                (SCVM_EXTRAPARAMS): Extra inputs to start/stop scripts. E.g. in above snapshot I have passed "add_to_etc_host=sample-scripted-cloud-node". I using this in my start script to IP of newly started VM to /etc/hosts on master to refer it by name in other steps.
  • Disconnect after Limited Builds: Will force the slave agent to disconnect after the specified number of builds have been performed,
    triggering the disconnect action.
  • What to do when the slave is disconnected: Action to perform (Shutdown, Revert, Reset, Nothing) when the slave is disconnected, either
    manually or via Jenkins.
  • Following are environment variables set in addition to above inputs:
    • SCVM_ACTION : "start" while calling start script and "stop" while calling stop script
    • SCVM_STOPACTION : This corresponds to the value of "Availability". Values are: "shutdown", "restart", "reset"

You can just check what all environment variables are available to start/stop script by adding "set" or "env" command in start/stop scripts. Environment variables set by this plugin starts with "SCVM".

Scripted cloud scripts mentioned by user can use these variables in any way. Plugin just assumes that VM slave is ready and connected when start script ends.

Developer Notes

I have following basic scenarios successfully:

  • choosing ssh mechanism in slave launch method and shutdown as action in end
  • choosing java web start in slave launch method and shutdown as action in end

Planning to remove following configuration :

  • "Disconnect after Limited Builds" : This does not matter to user much so I will remove it to avoid confusion.

Change Log

Version 0.1 (May 25, 2102)

7 Comments

  1. Unknown User (hisatti77)

    Do not use the attached plugin file .. it has bugs related to launching of slave agent.

    Somebody Please tell me how to remove it from this page.

  2. Unknown User (fgutierrez)

    I have been testing this plugin but sometimes, after a compilation, node shows that it's out of line, machine is actually switched off, but project, when launched again, it cannot start the virtual machine, meanwhile log shows this:

    sCCL::prelaunch
    
    [Node name] Event - Launch. slave:Linux[state:started, idleaction:Shutdown] 
    
    [Node name] Slave is already being launched
    

    The only way I've found to make it run again is to restart jenkins service, then node starts correctly when project runs.

    Node settings:

    • Leave this machine for tied jobs only
    • Force launch: true
    • Slave launch method: remote agent SSH
    • Availabillity: Take this slave on-line when in demand and off-line when idle.
    • What to do when the slave is disconnected: Shutdown.

    Thank you.

    1. Unknown User (hisatti77)

      Hi

          I too have noticed this behavior sometimes. It works fine when jenkins runs on on my windows machine  but shows this erroneous behavior many times on linux.
      I am too busy with other stuff these days that I am unable to look into this bug. 
      Hopefully I will get some time and fix this soon.

      Meanwhile pick latest one from http://updates.jenkins-ci.org/download/plugins/scripted-cloud-plugin/  in case you haven't done so, may be it works fine.

      1. Unknown User (fgutierrez)

        Hi Satinder,

        Thank you very much for your fast response.

        I have last version installed, master is in Windows Machine, slave is a linux machine.

        I have been testing for two weeks, and it goes wrong twice or three times every week. The worst is that the only way I have found to solve it temporaly is to restart Jenkins. Do you know any other way?

        I look forward to news from you, it's very interesting for me.

        Many thanks again for paying me attention and for your work.

  3. Unknown User (feoff3)

    I've got my own fork:

    https://github.com/feoff3/scripted-cloud-plugin

    I want to develop the plugin 'cause right now it doesn't support lots of nice features and behaves strangely.

    1. Unknown User (hisatti77)

      Hi Vladimir! I have added you as collaborator on github. You can modify the plugin as per your needs. 

  4. Unknown User (sash_kan)

    "disconnect after limited builds" — this item is not present in the create/update node dialog.