org.jenkinsci.plugins.scriptler
Class ScriptlerManagment

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

@Extension
public class ScriptlerManagment
extends hudson.model.ManagementLink
implements hudson.model.RootAction

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

Author:
Dominik Bartholdi (imod)

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
 boolean allowRunScriptEdit()
           
 boolean allowRunScriptPermission()
           
 boolean disableRemoteCatalog()
           
 org.kohsuke.stapler.HttpResponse doDownloadScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String id, 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, String id)
          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, String id)
          Removes a script from the config and filesystem.
 void doRunScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String id)
          Display the screen to trigger a script.
 org.kohsuke.stapler.HttpResponse doScriptAdd(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String id, String name, String comment, String script, boolean nonAdministerUsing, String originCatalogName, String originId)
          Saves a script snipplet as file to the system.
 org.kohsuke.stapler.HttpResponse doScriptlerSettings(org.kohsuke.stapler.StaplerRequest res, org.kohsuke.stapler.StaplerResponse rsp, boolean disableRemoteCatalog, boolean allowRunScriptPermission, boolean allowRunScriptEdit)
          save the scriptler 'global' settings (on settings screen, not global Jenkins config)
 void doTriggerScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String id, String scriptSrc, 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.
 ScriptInfoCatalog<? extends ScriptInfo> getCatalogByName(String catalogName)
           
 CatalogInfo getCatalogInfoByName(String catalogName)
           
 List<ScriptInfoCatalog> getCatalogs()
          Gets the remote catalogs containing the available scripts for download.
 ScriptlerConfiguration getConfiguration()
           
 String getDescription()
           
 String getDisplayName()
           
 String getIconFileName()
           
 String getPluginResourcePath()
           
static File getScriptDirectory()
          returns the directory where the script files get stored
 ScriptlerManagment getScriptler()
           
static File getScriptlerHomeDirectory()
           
 List<String> getSlaveAlias()
          Gets the names of all configured slaves, regardless whether they are online, including alias of ALL and ALL_SLAVES
 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 String getIconFileName()
Specified by:
getIconFileName in interface hudson.model.Action
Specified by:
getIconFileName in class hudson.model.ManagementLink

getUrlName

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

disableRemoteCatalog

public boolean disableRemoteCatalog()

allowRunScriptEdit

public boolean allowRunScriptEdit()

allowRunScriptPermission

public boolean allowRunScriptPermission()

getDisplayName

public String getDisplayName()
Specified by:
getDisplayName in interface hudson.model.Action
Specified by:
getDisplayName in interface hudson.model.ModelObject

getDescription

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

getScriptler

public ScriptlerManagment getScriptler()

getConfiguration

public ScriptlerConfiguration getConfiguration()

getPluginResourcePath

public String getPluginResourcePath()

doScriptlerSettings

public org.kohsuke.stapler.HttpResponse doScriptlerSettings(org.kohsuke.stapler.StaplerRequest res,
                                                            org.kohsuke.stapler.StaplerResponse rsp,
                                                            @QueryParameter(value="disableRemoteCatalog")
                                                            boolean disableRemoteCatalog,
                                                            @QueryParameter(value="allowRunScriptPermission")
                                                            boolean allowRunScriptPermission,
                                                            @QueryParameter(value="allowRunScriptEdit")
                                                            boolean allowRunScriptEdit)
                                                     throws IOException
save the scriptler 'global' settings (on settings screen, not global Jenkins config)

Parameters:
res -
rsp -
disableRemoteCatalog -
allowRunScriptPermission -
allowRunScriptEdit -
Returns:
Throws:
IOException

doDownloadScript

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

Parameters:
res - request
rsp - response
id - the id of the file to be downloaded
catalogName - the catalog to download the file from
Returns:
same forward as from doScriptAdd
Throws:
IOException
javax.servlet.ServletException

doScriptAdd

public org.kohsuke.stapler.HttpResponse doScriptAdd(org.kohsuke.stapler.StaplerRequest req,
                                                    org.kohsuke.stapler.StaplerResponse rsp,
                                                    @QueryParameter(value="id")
                                                    String id,
                                                    @QueryParameter(value="name")
                                                    String name,
                                                    @QueryParameter(value="comment")
                                                    String comment,
                                                    @QueryParameter(value="script")
                                                    String script,
                                                    @QueryParameter(value="nonAdministerUsing")
                                                    boolean nonAdministerUsing,
                                                    String originCatalogName,
                                                    String originId)
                                             throws IOException,
                                                    javax.servlet.ServletException
Saves a script snipplet as file to the system.

Parameters:
req - response
rsp - request
id - the script id (fileName)
name - the name of the script
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:
IOException
javax.servlet.ServletException

doRemoveScript

public org.kohsuke.stapler.HttpResponse doRemoveScript(org.kohsuke.stapler.StaplerRequest res,
                                                       org.kohsuke.stapler.StaplerResponse rsp,
                                                       @QueryParameter(value="id")
                                                       String id)
                                                throws 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:
IOException

doUploadScript

public org.kohsuke.stapler.HttpResponse doUploadScript(org.kohsuke.stapler.StaplerRequest req)
                                                throws 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:
IOException
javax.servlet.ServletException

doRunScript

public void doRunScript(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp,
                        @QueryParameter(value="id")
                        String id)
                 throws 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:
IOException
javax.servlet.ServletException

doTriggerScript

public void doTriggerScript(org.kohsuke.stapler.StaplerRequest req,
                            org.kohsuke.stapler.StaplerResponse rsp,
                            @QueryParameter(value="id")
                            String id,
                            @QueryParameter(value="script")
                            String scriptSrc,
                            @QueryParameter(value="node")
                            String node)
                     throws 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
scriptSrc - the script code (groovy)
node - the node, to execute the code on.
Throws:
IOException
javax.servlet.ServletException

doEditScript

public void doEditScript(org.kohsuke.stapler.StaplerRequest req,
                         org.kohsuke.stapler.StaplerResponse rsp,
                         @QueryParameter(value="id")
                         String id)
                  throws 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:
IOException
javax.servlet.ServletException

getSlaveAlias

public List<String> getSlaveAlias()
Gets the names of all configured slaves, regardless whether they are online, including alias of ALL and ALL_SLAVES

Returns:
list with all slave names

getCatalogs

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

Returns:
the catalog

getCatalogByName

public ScriptInfoCatalog<? extends ScriptInfo> getCatalogByName(String catalogName)

getCatalogInfoByName

public CatalogInfo getCatalogInfoByName(String catalogName)

getScriptDirectory

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

Returns:
the script directory

getScriptlerHomeDirectory

public static File getScriptlerHomeDirectory()


Copyright © 2010-2012. All Rights Reserved.