Class CNHudsonUtil


  • public class CNHudsonUtil
    extends Object
    Class for methods that are useful across Jenkins plugins.
    • Method Detail

      • getCollabNetApp

        public static CollabNetApp getCollabNetApp​(String url,
                                                   String username,
                                                   String password)
        Parameters:
        url - the teamforge url
        username - the teamforge username
        password - credential of the user
        Returns:
        collabnet app, if one can be created; null otherwise.
      • recreateCollabNetApp

        public static CollabNetApp recreateCollabNetApp​(String url,
                                                        String username,
                                                        String sessionId)
        Parameters:
        url - the teamforge url
        username - the teamforge username
        sessionId - user sessionId
        Returns:
        collabnet app, if one can be created; null otherwise.
      • getCollabNetApp

        public static CollabNetApp getCollabNetApp​(org.kohsuke.stapler.StaplerRequest request)
        Get a CollabNetApp, given a StaplerRequest with url, username, and password set. If login fails, null will be returned.
      • getUsername

        public static String getUsername​(org.kohsuke.stapler.StaplerRequest request)
        Returns:
        the username from the stapler request or the global value, if applicable.
      • logoff

        public static void logoff​(CollabNetApp cna)
        Logs off the CollabNetApp, if possible.
        Parameters:
        cna - CollabNetApp
      • getProjectReleaseId

        public static CTFRelease getProjectReleaseId​(CTFProject project,
                                                     String release)
                                              throws IOException
        Get a releaseId, given a projectId and a release title.
        Parameters:
        release - name of the release
        Returns:
        the releaseId in this project which matches the release name or null if none is found.
        Throws:
        IOException
      • isUserValid

        public static boolean isUserValid​(CollabNetApp cna,
                                          String username)
        Parameters:
        cna - for accessing the webservice methods.
        username - username
        Returns:
        true if the user can be found.
      • getScmViewerUrl

        public static String getScmViewerUrl​(CollabNetApp cna,
                                             String collabnetUrl,
                                             String projectName,
                                             String repoName)
                                      throws IOException
        Parameters:
        cna - for accessing the webservice methods.
        collabnetUrl - the collabnet url
        projectName - name of the project
        repoName - name of the repository
        Returns:
        the scm viewer url
        Throws:
        IOException
      • getVersionArray

        public static int[] getVersionArray​(String apiVersionStr)
        Turn version string into an array, where each version is in its own index/pos.
        Parameters:
        apiVersionStr - apiVersionStr
        Returns:
        array of version strings in int format
      • getSystemId

        public static String getSystemId​(CollabNetApp cna,
                                         String projectName,
                                         String repoName)
                                  throws IOException
        Parameters:
        cna - for accessing the webservice methods.
        projectName - the project name
        repoName - the repo name
        Returns:
        system id
        Throws:
        IOException
      • sanitizeCollabNetUrl

        public static String sanitizeCollabNetUrl​(String url)
        Sanitizes a CollabNet url and make it appropriate to be used by this plugin.
        Parameters:
        url - original url
        Returns:
        sanitized collabnet url