Package hudson.plugins.collabnet.util
Class CNHudsonUtil
- java.lang.Object
-
- hudson.plugins.collabnet.util.CNHudsonUtil
-
public class CNHudsonUtil extends Object
Class for methods that are useful across Jenkins plugins.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CollabNetApp
getCollabNetApp(String url, String username, String password)
static CollabNetApp
getCollabNetApp(org.kohsuke.stapler.StaplerRequest request)
Get a CollabNetApp, given a StaplerRequest with url, username, and password set.static CTFRelease
getProjectReleaseId(CTFProject project, String release)
Get a releaseId, given a projectId and a release title.static String
getScmViewerUrl(CollabNetApp cna, String collabnetUrl, String projectName, String repoName)
static String
getSystemId(CollabNetApp cna, String projectName, String repoName)
static String
getUsername(org.kohsuke.stapler.StaplerRequest request)
static int[]
getVersionArray(String apiVersionStr)
Turn version string into an array, where each version is in its own index/pos.static boolean
isUserValid(CollabNetApp cna, String username)
static void
logoff(CollabNetApp cna)
Logs off the CollabNetApp, if possible.static CollabNetApp
recreateCollabNetApp(String url, String username, String sessionId)
static String
sanitizeCollabNetUrl(String url)
Sanitizes a CollabNet url and make it appropriate to be used by this plugin.
-
-
-
Method Detail
-
getCollabNetApp
public static CollabNetApp getCollabNetApp(String url, String username, String password)
- Parameters:
url
- the teamforge urlusername
- the teamforge usernamepassword
- 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 urlusername
- the teamforge usernamesessionId
- 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 urlprojectName
- name of the projectrepoName
- 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 namerepoName
- the repo name- Returns:
- system id
- Throws:
IOException
-
-