org.jvnet.hudson.plugins.scriptler
Class ScriptlerManagment

java.lang.Object
  extended by hudson.model.ManagementLink
      extended by org.jvnet.hudson.plugins.scriptler.ScriptlerManagment
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Action, hudson.model.ModelObject

@Extension
public class ScriptlerManagment
extends hudson.model.ManagementLink

Creates the link on the "manage hudson" page and handles all the web requests.

Author:
domi

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 
Fields inherited from class hudson.model.ManagementLink
LIST
 
Constructor Summary
ScriptlerManagment()
           
 
Method Summary
 org.kohsuke.stapler.HttpResponse doDownloadScript(org.kohsuke.stapler.StaplerRequest res, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String id, java.lang.String catalogName)
          Downloads a script from a catalog and imports it to the local system.
 void doEditScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String scriptName)
          Loads the script by its name and forwards the request to "edit.jelly".
 org.kohsuke.stapler.HttpResponse doRemoveScript(org.kohsuke.stapler.StaplerRequest res, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String name)
          Removes a script from the config and filesystem.
 void doRunScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String scriptName)
          Display the screen to trigger a script.
 org.kohsuke.stapler.HttpResponse doScriptAdd(org.kohsuke.stapler.StaplerRequest res, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String name, java.lang.String comment, java.lang.String script, java.lang.String originCatalogName, java.lang.String originId)
          Saves a script snipplet as file to the system.
 void doTriggerScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String scriptName, java.lang.String script, java.lang.String node)
          Trigger/run/execute the script on a slave and show the result/output.
 org.kohsuke.stapler.HttpResponse doUploadScript(org.kohsuke.stapler.StaplerRequest req)
          Uploads a script and stores it with the given filename to the configuration.
 CatalogInfo getCatalogInfoByName(java.lang.String catalogName)
           
 java.util.List<Catalog> getCatalogs()
          Gets the remote catalogs containing the available scripts for download.
 ScriptlerConfiguration getConfiguration()
           
 java.lang.String getDescription()
           
 java.lang.String getDisplayName()
           
 java.lang.String getIconFileName()
           
protected  Script getScript(java.lang.String scriptName, boolean withSrc)
          Loads the script information.
static java.io.File getScriptDirectory()
          returns the directory where the script files get stored
 ScriptlerManagment getScriptler()
           
static java.io.File getScriptlerHomeDirectory()
           
 java.util.List<java.lang.String> getSlaveNames()
          Gets the names of all configured slaves, regardless whether they are online.
 java.lang.String getUrlName()
           
 
Methods inherited from class hudson.model.ManagementLink
all
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptlerManagment

public ScriptlerManagment()
Method Detail

getIconFileName

public java.lang.String getIconFileName()
Specified by:
getIconFileName in interface hudson.model.Action
Specified by:
getIconFileName in class hudson.model.ManagementLink

getUrlName

public java.lang.String getUrlName()
Specified by:
getUrlName in interface hudson.model.Action
Specified by:
getUrlName in class hudson.model.ManagementLink

getDisplayName

public java.lang.String getDisplayName()

getDescription

public java.lang.String getDescription()
Overrides:
getDescription in class hudson.model.ManagementLink

getScriptler

public ScriptlerManagment getScriptler()

getConfiguration

public ScriptlerConfiguration getConfiguration()

doDownloadScript

public org.kohsuke.stapler.HttpResponse doDownloadScript(org.kohsuke.stapler.StaplerRequest res,
                                                         org.kohsuke.stapler.StaplerResponse rsp,
                                                         @QueryParameter(value="id")
                                                         java.lang.String id,
                                                         @QueryParameter(value="catalog")
                                                         java.lang.String catalogName)
                                                  throws java.io.IOException
Downloads a script from a catalog and imports it to the local system.

Parameters:
res - request
rsp - response
name - the name of the file to be downloaded
catalogName - the catalog to download the file from
Returns:
same forward as from doScriptAdd
Throws:
java.io.IOException

doScriptAdd

public org.kohsuke.stapler.HttpResponse doScriptAdd(org.kohsuke.stapler.StaplerRequest res,
                                                    org.kohsuke.stapler.StaplerResponse rsp,
                                                    @QueryParameter(value="name")
                                                    java.lang.String name,
                                                    @QueryParameter(value="comment")
                                                    java.lang.String comment,
                                                    @QueryParameter(value="script")
                                                    java.lang.String script,
                                                    java.lang.String originCatalogName,
                                                    java.lang.String originId)
                                             throws java.io.IOException
Saves a script snipplet as file to the system.

Parameters:
res - response
rsp - request
name - the name for the file
comment - a comment
script - script code
catalogName - (optional) the name of the catalog the script is loaded/added from
originId - (optional) the original id the script had at the catalog
Returns:
forward to 'index'
Throws:
java.io.IOException

doRemoveScript

public org.kohsuke.stapler.HttpResponse doRemoveScript(org.kohsuke.stapler.StaplerRequest res,
                                                       org.kohsuke.stapler.StaplerResponse rsp,
                                                       @QueryParameter(value="name")
                                                       java.lang.String name)
                                                throws java.io.IOException
Removes a script from the config and filesystem.

Parameters:
res - response
rsp - request
name - the name of the file to be removed
Returns:
forward to 'index'
Throws:
java.io.IOException

doUploadScript

public org.kohsuke.stapler.HttpResponse doUploadScript(org.kohsuke.stapler.StaplerRequest req)
                                                throws java.io.IOException,
                                                       javax.servlet.ServletException
Uploads a script and stores it with the given filename to the configuration. It will be stored on the filessytem.

Parameters:
req - request
Returns:
forward to index page.
Throws:
java.io.IOException
javax.servlet.ServletException

getScript

protected Script getScript(java.lang.String scriptName,
                           boolean withSrc)
Loads the script information.

Parameters:
scriptName - the name of the script
withSrc - should the script sources be loaded too?
Returns:
the script

doRunScript

public void doRunScript(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp,
                        @QueryParameter(value="name")
                        java.lang.String scriptName)
                 throws java.io.IOException,
                        javax.servlet.ServletException
Display the screen to trigger a script. The source of the script get loaded from the filesystem and placed in the request to display it on the page before execution.

Parameters:
req - request
rsp - response
scriptName - the name of the script to be executed
Throws:
java.io.IOException
javax.servlet.ServletException

doTriggerScript

public void doTriggerScript(org.kohsuke.stapler.StaplerRequest req,
                            org.kohsuke.stapler.StaplerResponse rsp,
                            @QueryParameter(value="scriptName")
                            java.lang.String scriptName,
                            @QueryParameter(value="script")
                            java.lang.String script,
                            @QueryParameter(value="node")
                            java.lang.String node)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Trigger/run/execute the script on a slave and show the result/output. The request then gets forward to runscript.jelly (This is usually also where the request came from). The script passed to this method gets restored in the request again (and not loaded from the system). This way one is able to modify the script before execution and reuse the modified version for further executions.

Parameters:
req - request
rsp - response
scriptName - the name of the script
script - the script code (groovy)
node - the node, to execute the code on.
Throws:
java.io.IOException
javax.servlet.ServletException

doEditScript

public void doEditScript(org.kohsuke.stapler.StaplerRequest req,
                         org.kohsuke.stapler.StaplerResponse rsp,
                         @QueryParameter(value="name")
                         java.lang.String scriptName)
                  throws java.io.IOException,
                         javax.servlet.ServletException
Loads the script by its name and forwards the request to "edit.jelly".

Parameters:
req - request
rsp - response
scriptName - the name of the script to be loaded in to the edit view.
Throws:
java.io.IOException
javax.servlet.ServletException

getSlaveNames

public java.util.List<java.lang.String> getSlaveNames()
Gets the names of all configured slaves, regardless whether they are online.

Returns:
list with all slave names

getCatalogs

public java.util.List<Catalog> getCatalogs()
Gets the remote catalogs containing the available scripts for download.

Returns:
the catalog

getCatalogInfoByName

public CatalogInfo getCatalogInfoByName(java.lang.String catalogName)

getScriptDirectory

public static java.io.File getScriptDirectory()
returns the directory where the script files get stored

Returns:
the script directory

getScriptlerHomeDirectory

public static java.io.File getScriptlerHomeDirectory()


Copyright © 2010. All Rights Reserved.