Class ScriptlerManagement

    • Constructor Detail

      • ScriptlerManagement

        public ScriptlerManagement()
    • Method Detail

      • getScriptlerRunScripts

        public Permission getScriptlerRunScripts()
      • getScriptlerConfigure

        public Permission getScriptlerConfigure()
      • hasAtLeastOneScriptlerPermission

        public boolean hasAtLeastOneScriptlerPermission()
      • checkAtLeastOneScriptlerPermission

        public void checkAtLeastOneScriptlerPermission()
      • disableRemoteCatalog

        public boolean disableRemoteCatalog()
      • doScriptlerSettings

        public org.kohsuke.stapler.HttpResponse doScriptlerSettings​(org.kohsuke.stapler.StaplerRequest res,
                                                                    org.kohsuke.stapler.StaplerResponse rsp,
                                                                    @QueryParameter("disableRemoteCatalog")
                                                                    boolean disableRemoteCatalog)
                                                             throws IOException
        save the scriptler 'global' settings (on settings screen, not global Jenkins config)
        Parameters:
        res -
        rsp -
        disableRemoteCatalog -
        Returns:
        Throws:
        IOException
      • doDownloadScript

        public org.kohsuke.stapler.HttpResponse doDownloadScript​(org.kohsuke.stapler.StaplerRequest req,
                                                                 org.kohsuke.stapler.StaplerResponse 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 - 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
      • doScriptAdd

        public org.kohsuke.stapler.HttpResponse doScriptAdd​(org.kohsuke.stapler.StaplerRequest req,
                                                            org.kohsuke.stapler.StaplerResponse rsp,
                                                            @QueryParameter("id")
                                                            String id,
                                                            @QueryParameter("name")
                                                            String name,
                                                            @QueryParameter("comment")
                                                            String comment,
                                                            @QueryParameter("script")
                                                            String script,
                                                            @QueryParameter("nonAdministerUsing")
                                                            boolean nonAdministerUsing,
                                                            @QueryParameter("onlyMaster")
                                                            boolean onlyMaster,
                                                            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
        nonAdministerUsing - allow usage in Scriptler build step
        onlyMaster - this script is only allwoed to run on the master node
        originCatalogName - (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
      • doHardResetGit

        public org.kohsuke.stapler.HttpResponse doHardResetGit()
                                                        throws IOException
        Triggers a hard reset on the git repo
        Returns:
        redirects to the repo entry page at http://jenkins.orga.com/scriptler.git
        Throws:
        IOException
      • doRemoveScript

        public org.kohsuke.stapler.HttpResponse doRemoveScript​(org.kohsuke.stapler.StaplerRequest res,
                                                               org.kohsuke.stapler.StaplerResponse rsp,
                                                               @QueryParameter("id")
                                                               String id)
                                                        throws IOException
        Removes a script from the config and filesystem.
        Parameters:
        res - response
        rsp - request
        id - the id 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("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
        id - the id 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("id")
                                    String id,
                                    @QueryParameter("script")
                                    String scriptSrc,
                                    @QueryParameter("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
        id - the id of the script
        scriptSrc - the script code (groovy)
        node - the node, to execute the code on.
        Throws:
        IOException
        javax.servlet.ServletException
      • doRun

        public void doRun​(org.kohsuke.stapler.StaplerRequest req,
                          org.kohsuke.stapler.StaplerResponse rsp,
                          @QueryParameter(fixEmpty=true)
                          String script,
                          @QueryParameter(fixEmpty=true)
                          String node,
                          @QueryParameter(fixEmpty=true)
                          String contentType)
                   throws IOException,
                          javax.servlet.ServletException
        Trigger/run/execute the script on a slave and directly forward the result/output to the response.
        Parameters:
        req - request
        rsp - response
        script - the script code (groovy)
        node - the node, to execute the code on, defaults to "(master)"
        contentType - the contentType to use in the response, defaults to text/plain
        Throws:
        IOException
        javax.servlet.ServletException
      • doShowScript

        public void doShowScript​(org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp,
                                 @AncestorInPath
                                 Item item,
                                 @QueryParameter("id")
                                 String id)
                          throws IOException,
                                 javax.servlet.ServletException
        Loads the script by its name and forwards the request to "show.jelly".
        Parameters:
        req - request
        rsp - response
        id - the id of the script to be loaded in to the show view.
        Throws:
        IOException
        javax.servlet.ServletException
      • doEditScript

        public void doEditScript​(org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp,
                                 @QueryParameter("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
        id - the id of the script to be loaded in to the edit view.
        Throws:
        IOException
        javax.servlet.ServletException
      • getSlaveAlias

        public List<String> getSlaveAlias​(Script script)
        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<? extends ScriptInfoCatalog<ScriptInfo>> getCatalogs()
        Gets the remote catalogs containing the available scripts for download.
        Returns:
        the catalog
      • 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()