Class JenkinsUtil


  • public class JenkinsUtil
    extends Object
    • Method Detail

      • getJenkins

        public static Jenkins getJenkins()
      • getBuildAgents

        public static List<Node> getBuildAgents()
        Get jenkins build agents without master node
        Returns:
        jenkins build agents without master node
      • getAllAgents

        public static List<Node> getAllAgents()
        Get all build agents that are part of the same CI build swarm.
        Returns:
        all build nodes including master (master is the last node in the list)
      • getOnlineComputers

        public static List<Computer> getOnlineComputers()
      • getComputerName

        public static String getComputerName​(Node agent)
      • getComputerName

        public static String getComputerName​(Computer computer)
      • getBuildJobs

        public static Set<String> getBuildJobs()
      • getJobs

        public static List<Job<?,​?>> getJobs​(AbstractProject<?,​?> project,
                                                   Collection<String> jobNames)
        Get jenkins jobs (projects that you can build) via specified job names. Job name is the unique name of the project, which you specify when you create a new jenkins project (freestyle, pipeline, etc...)
        Returns:
        list of relevant jobs that matches with the specified names.
      • getJob

        public static Job<?,​?> getJob​(AbstractProject<?,​?> project,
                                            String jobName)
                                     throws IllegalStateException
        Get a jenkins job class (project that you can build). Job name is unique name of the project which you specify when you create a new jenkins project (freestyle, pipeline)
        Throws:
        IllegalStateException - if job with specified name does not exist in Jenkins
      • getBuild

        public static Optional<Run<?,​?>> getBuild​(String projectName,
                                                        int buildNumber)
        Get the specific build from the chosen project.
        Returns:
        build or optional if the project or the build number do not exist
      • getBuildDurationString

        public static String getBuildDurationString​(Run<?,​?> build)
        Get human readable build duration
      • createConsoleLink

        public static String createConsoleLink​(Run<?,​?> build)
      • getPluginVersion

        public static String getPluginVersion​(String pluginName)