Package org.jenkinsci.plugins.scriptler
Class ScriptlerManagement
java.lang.Object
hudson.model.ManagementLink
org.jenkinsci.plugins.scriptler.ScriptlerManagement
- All Implemented Interfaces:
ExtensionPoint
,Action
,ModelObject
,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 class hudson.model.ManagementLink
ManagementLink.Category
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Fields inherited from class hudson.model.ManagementLink
LIST
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
org.kohsuke.stapler.HttpResponse
doDownloadScript
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String id, String catalogName) Downloads a script from a catalog and imports it to the local system.void
doEditScript
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String id) Loads the script by its name and forwards the request to "edit.jelly".org.kohsuke.stapler.HttpResponse
Triggers a hard reset on the git repoorg.kohsuke.stapler.HttpResponse
doRemoveScript
(org.kohsuke.stapler.StaplerRequest2 res, org.kohsuke.stapler.StaplerResponse2 rsp, String id) Removes a script from the config and filesystem.void
doRun
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String script, String node, String contentType) Trigger/run/execute the script on an agent and directly forward the result/output to the response.void
doRunScript
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String id) Display the screen to trigger a script.org.kohsuke.stapler.HttpResponse
doScriptAdd
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String id, String name, String comment, String script, boolean nonAdministerUsing, boolean onlyController, String originCatalogName, String originId) Saves a script snippet as file to the system.org.kohsuke.stapler.HttpResponse
doScriptlerSettings
(org.kohsuke.stapler.StaplerRequest2 res, org.kohsuke.stapler.StaplerResponse2 rsp, boolean disableRemoteCatalog) save the scriptler 'global' settings (on settings screen, not global Jenkins config)void
doShowScript
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Item item, String id) Loads the script by its name and forwards the request to "show.jelly".void
doTriggerScript
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String id, String scriptSrc, String node) Trigger/run/execute the script on an agent and show the result/output.org.kohsuke.stapler.HttpResponse
doUploadScript
(org.kohsuke.stapler.StaplerRequest2 req) Uploads a script and stores it with the given filename to the configuration.getCatalogByName
(String catalogName) getCatalogInfoByName
(String catalogName) Gets the remote catalogs containing the available scripts for download.getComputerAliases
(Script script) Gets the names of all configured computers, regardless whether they are online, including alias of ALL and ALL_AGENTSstatic File
Deprecated.static Path
returns the directory where the script files get storedstatic File
Deprecated.UsegetScriptlerHomeDirectory2()
instead.static Path
getSlaveAlias
(Script script) Deprecated.UsegetComputerAliases(Script)
instead.boolean
Methods inherited from class hudson.model.ManagementLink
all, getBadge, getCategoryName, getRequiredPermission, getRequiresConfirmation, getRequiresPOST
-
Constructor Details
-
ScriptlerManagement
public ScriptlerManagement()
-
-
Method Details
-
getScriptlerRunScripts
-
getScriptlerConfigure
-
hasAtLeastOneScriptlerPermission
public boolean hasAtLeastOneScriptlerPermission() -
checkAtLeastOneScriptlerPermission
public void checkAtLeastOneScriptlerPermission() -
getIconFileName
- Specified by:
getIconFileName
in interfaceAction
- Specified by:
getIconFileName
in classManagementLink
-
getCategory
- Overrides:
getCategory
in classManagementLink
-
getUrlName
- Specified by:
getUrlName
in interfaceAction
- Specified by:
getUrlName
in classManagementLink
-
disableRemoteCatalog
public boolean disableRemoteCatalog() -
getDisplayName
- Specified by:
getDisplayName
in interfaceAction
- Specified by:
getDisplayName
in interfaceModelObject
-
getDescription
- Overrides:
getDescription
in classManagementLink
-
getScriptler
-
getConfiguration
-
getMarkupFormatter
-
doScriptlerSettings
public org.kohsuke.stapler.HttpResponse doScriptlerSettings(org.kohsuke.stapler.StaplerRequest2 res, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("disableRemoteCatalog") boolean disableRemoteCatalog) throws IOException save the scriptler 'global' settings (on settings screen, not global Jenkins config)- Throws:
IOException
-
doDownloadScript
public org.kohsuke.stapler.HttpResponse doDownloadScript(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("id") String id, @QueryParameter("catalog") String catalogName) throws IOException Downloads a script from a catalog and imports it to the local system.- Parameters:
req
- requestrsp
- responseid
- the id of the file to be downloadedcatalogName
- the catalog to download the file from- Returns:
- same forward as from
doScriptAdd
- Throws:
IOException
-
doScriptAdd
public org.kohsuke.stapler.HttpResponse doScriptAdd(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("id") String id, @QueryParameter("name") String name, @QueryParameter("comment") String comment, @QueryParameter("script") String script, @QueryParameter("nonAdministerUsing") boolean nonAdministerUsing, @QueryParameter("onlyController") boolean onlyController, String originCatalogName, String originId) throws IOException, jakarta.servlet.ServletException Saves a script snippet as file to the system.- Parameters:
req
- responsersp
- requestid
- the script id (fileName)name
- the name of the scriptcomment
- a commentscript
- script codenonAdministerUsing
- allow usage in Scriptler build steponlyController
- this script is only allowed to run on the controlleroriginCatalogName
- (optional) the name of the catalog the script is loaded/added fromoriginId
- (optional) the original id the script had at the catalog- Returns:
- forward to 'index'
- Throws:
IOException
jakarta.servlet.ServletException
-
getGitRepo
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public GitScriptlerRepository getGitRepo() -
doHardResetGit
Triggers a hard reset on the git repo- Returns:
- redirects to the repo entry page at
/scriptler.git
- Throws:
IOException
-
doRemoveScript
public org.kohsuke.stapler.HttpResponse doRemoveScript(org.kohsuke.stapler.StaplerRequest2 res, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("id") String id) throws IOException Removes a script from the config and filesystem.- Parameters:
res
- responsersp
- requestid
- the id of the file to be removed- Returns:
- forward to 'index'
- Throws:
IOException
-
doUploadScript
public org.kohsuke.stapler.HttpResponse doUploadScript(org.kohsuke.stapler.StaplerRequest2 req) throws IOException, jakarta.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
jakarta.servlet.ServletException
-
doRunScript
public void doRunScript(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("id") String id) throws IOException, jakarta.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
- requestrsp
- responseid
- the id of the script to be executed- Throws:
IOException
jakarta.servlet.ServletException
-
doTriggerScript
public void doTriggerScript(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("id") String id, @QueryParameter("script") String scriptSrc, @QueryParameter("node") String node) throws IOException, jakarta.servlet.ServletException Trigger/run/execute the script on an agent and show the result/output. The request then gets forward torunScript.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
- requestrsp
- responseid
- the id of the scriptscriptSrc
- the script code (groovy)node
- the node to execute the code on.- Throws:
IOException
jakarta.servlet.ServletException
-
doRun
public void doRun(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter(fixEmpty=true) String script, @QueryParameter(fixEmpty=true) String node, @QueryParameter(fixEmpty=true) String contentType) throws IOException, jakarta.servlet.ServletException Trigger/run/execute the script on an agent and directly forward the result/output to the response.- Parameters:
req
- requestrsp
- responsescript
- the script code (groovy)node
- the node, to execute the code on, defaults to "(controller)"contentType
- the contentType to use in the response, defaults to text/plain- Throws:
IOException
jakarta.servlet.ServletException
-
doShowScript
public void doShowScript(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @AncestorInPath Item item, @QueryParameter("id") String id) throws IOException, jakarta.servlet.ServletException Loads the script by its name and forwards the request to "show.jelly".- Parameters:
req
- requestrsp
- responseid
- the id of the script to be loaded in to the show view.- Throws:
IOException
jakarta.servlet.ServletException
-
doEditScript
public void doEditScript(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter("id") String id) throws IOException, jakarta.servlet.ServletException Loads the script by its name and forwards the request to "edit.jelly".- Parameters:
req
- requestrsp
- responseid
- the id of the script to be loaded in to the edit view.- Throws:
IOException
jakarta.servlet.ServletException
-
getSlaveAlias
Deprecated.UsegetComputerAliases(Script)
instead. -
getComputerAliases
Gets the names of all configured computers, regardless whether they are online, including alias of ALL and ALL_AGENTS- Returns:
- list with all computer names
-
getCatalogs
Gets the remote catalogs containing the available scripts for download.- Returns:
- the catalog
-
getCatalogByName
-
getCatalogInfoByName
-
getScriptDirectory
Deprecated.UsegetScriptDirectory2()
instead. -
getScriptDirectory2
returns the directory where the script files get stored- Returns:
- the script directory
-
getScriptlerHomeDirectory
Deprecated.UsegetScriptlerHomeDirectory2()
instead. -
getScriptlerHomeDirectory2
-
getScriptDirectory2()
instead.