Package hudson.plugins.sauce_ondemand
Class SauceOnDemandBuildAction
- java.lang.Object
-
- hudson.plugins.sauce_ondemand.AbstractAction
-
- hudson.plugins.sauce_ondemand.SauceOnDemandBuildAction
-
- All Implemented Interfaces:
Action
,ModelObject
,Serializable
,RunAction2
,SimpleBuildStep.LastBuildAction
@ExportedBean public class SauceOnDemandBuildAction extends AbstractAction implements Serializable, RunAction2, SimpleBuildStep.LastBuildAction
Presents the links to the Sauce OnDemand jobs on the build summary page.- Author:
- Ross Rowe
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
SESSION_ID_PATTERN
Regex pattern that is used to identify Sauce job ids which have been run as part of a Jenkins build.
-
Constructor Summary
Constructors Constructor Description SauceOnDemandBuildAction(Run build, String credentialsId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doJobReport(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
Map<String,String>
getAnalytics()
Run
getBuild()
SauceTestResultsById
getById(String id)
protected SauceCredentials
getCredentials()
protected static List<String>
getJobIdsForBuild(JenkinsSauceREST sauceREST, String buildId)
List<JenkinsJobInformation>
getJobs()
List<JenkinsJobInformation>
getJobs(boolean updateJobs)
protected static Map<String,JenkinsJobInformation>
getJobsInformation(JenkinsSauceREST sauceREST, SauceCredentials credentials, Iterable<String> jobIds)
Collection<? extends Action>
getProjectActions()
JenkinsBuildInformation
getSauceBuild()
JenkinsBuildInformation
getSauceBuild(boolean updateBuild)
Default method of getting Sauce build information using the sanitized Jenkins build numberJenkinsBuildInformation
getSauceBuild(String sauceBuildName)
JenkinsBuildInformation
getSauceBuild(String sauceBuildName, boolean updateBuild)
Method for getting Sauce build information if we know the actual Sauce build namestatic SauceOnDemandBuildAction
getSauceBuildAction(Run build)
protected JenkinsSauceREST
getSauceREST()
boolean
hasSauceOnDemandResults()
void
onAttached(Run<?,?> run)
void
onLoad(Run<?,?> run)
protected Object
readResolve()
static JenkinsBuildInformation
retrieveBuildFromSauce(JenkinsSauceREST sauceREST, String buildNumber)
Invokes the Sauce REST API to retrieve the build information.static JenkinsBuildInformation
retrieveBuildInformationFromSauce(JenkinsSauceREST sauceREST, String buildNumber)
Invokes the Sauce REST API to retrieve the build information.static LinkedHashMap<String,JenkinsJobInformation>
retrieveJobIdsFromSauce(JenkinsSauceREST sauceREST, Run build)
Invokes the Sauce REST API to retrieve the details for the jobs the user has access to.static LinkedHashMap<String,JenkinsJobInformation>
retrieveJobIdsFromSauce(JenkinsSauceREST sauceREST, Run build, SauceCredentials credentials)
void
setJobs(List<JenkinsJobInformation> jobs)
protected static List<List<String>>
slice(Iterable<String> strings, int sliceSize)
void
stopJobs()
void
updateJobs(Map<String,String> customDataObj)
-
Methods inherited from class hudson.plugins.sauce_ondemand.AbstractAction
getDisplayName, getIconFileName, getJobsWithAuth, getUrlName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface hudson.model.Action
getDisplayName, getIconFileName, getUrlName
-
-
-
-
Field Detail
-
SESSION_ID_PATTERN
public static final Pattern SESSION_ID_PATTERN
Regex pattern that is used to identify Sauce job ids which have been run as part of a Jenkins build.
-
-
Method Detail
-
retrieveBuildFromSauce
public static JenkinsBuildInformation retrieveBuildFromSauce(JenkinsSauceREST sauceREST, String buildNumber) throws org.json.JSONException
Invokes the Sauce REST API to retrieve the build information.- Parameters:
sauceREST
- Sauce Rest object/credentials to usebuildNumber
- The build name on Sauce or sanitized build number from Jenkins- Returns:
- Jenkins build information
- Throws:
org.json.JSONException
- Not json returned properly
-
retrieveBuildInformationFromSauce
public static JenkinsBuildInformation retrieveBuildInformationFromSauce(JenkinsSauceREST sauceREST, String buildNumber) throws org.json.JSONException, IOException
Invokes the Sauce REST API to retrieve the build information.- Parameters:
sauceREST
- Sauce Rest object/credentials to usebuildNumber
- The build name on Sauce or sanitized build number from Jenkins- Returns:
- Jenkins build information
- Throws:
org.json.JSONException
- Unable to parse jsonIOException
-
retrieveJobIdsFromSauce
public static LinkedHashMap<String,JenkinsJobInformation> retrieveJobIdsFromSauce(JenkinsSauceREST sauceREST, Run build) throws org.json.JSONException, IOException
Invokes the Sauce REST API to retrieve the details for the jobs the user has access to. Iterates over the jobs and attempts to find the job that has a 'build' field matching the build key/number.- Parameters:
sauceREST
- Sauce Rest object/credentials to usebuild
- Which build this is requesting job ids from- Returns:
- List of processed job information
- Throws:
org.json.JSONException
- Not json returned properlyIOException
-
getSauceBuildAction
public static SauceOnDemandBuildAction getSauceBuildAction(Run build)
- Parameters:
build
- The build in progress- Returns:
- the
SauceOnDemandBuildAction
instance which has been registered with the build Can be null
-
retrieveJobIdsFromSauce
public static LinkedHashMap<String,JenkinsJobInformation> retrieveJobIdsFromSauce(JenkinsSauceREST sauceREST, Run build, SauceCredentials credentials) throws org.json.JSONException, IOException
- Throws:
org.json.JSONException
IOException
-
getJobIdsForBuild
protected static List<String> getJobIdsForBuild(JenkinsSauceREST sauceREST, String buildId)
-
getJobsInformation
protected static Map<String,JenkinsJobInformation> getJobsInformation(JenkinsSauceREST sauceREST, SauceCredentials credentials, Iterable<String> jobIds) throws org.json.JSONException, IOException
- Throws:
org.json.JSONException
IOException
-
getBuild
public Run getBuild()
-
hasSauceOnDemandResults
public boolean hasSauceOnDemandResults()
-
getSauceBuild
@Exported(visibility=2) public JenkinsBuildInformation getSauceBuild(boolean updateBuild)
Default method of getting Sauce build information using the sanitized Jenkins build number
-
getSauceBuild
@Exported(visibility=2) public JenkinsBuildInformation getSauceBuild()
-
getSauceBuild
@Exported(visibility=2) public JenkinsBuildInformation getSauceBuild(String sauceBuildName, boolean updateBuild)
Method for getting Sauce build information if we know the actual Sauce build name
-
getSauceBuild
@Exported(visibility=2) public JenkinsBuildInformation getSauceBuild(String sauceBuildName)
-
getJobs
@Exported(visibility=2) public List<JenkinsJobInformation> getJobs(boolean updateJobs)
-
getJobs
@Exported(visibility=2) public List<JenkinsJobInformation> getJobs()
- Specified by:
getJobs
in classAbstractAction
-
stopJobs
public void stopJobs() throws InterruptedException
- Throws:
InterruptedException
-
updateJobs
public void updateJobs(Map<String,String> customDataObj) throws IOException
- Throws:
IOException
-
getCredentials
protected SauceCredentials getCredentials()
- Specified by:
getCredentials
in classAbstractAction
-
getSauceREST
protected JenkinsSauceREST getSauceREST()
-
getById
public SauceTestResultsById getById(String id)
-
doJobReport
public void doJobReport(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
- Overrides:
doJobReport
in classAbstractAction
- Parameters:
req
- Standard Request Objectrsp
- Standard Response Object- Throws:
IOException
- Unable to load index.jelly template
-
setJobs
public void setJobs(List<JenkinsJobInformation> jobs)
-
readResolve
protected Object readResolve()
-
getProjectActions
public Collection<? extends Action> getProjectActions()
- Specified by:
getProjectActions
in interfaceSimpleBuildStep.LastBuildAction
-
onAttached
public void onAttached(Run<?,?> run)
- Specified by:
onAttached
in interfaceRunAction2
-
onLoad
public void onLoad(Run<?,?> run)
- Specified by:
onLoad
in interfaceRunAction2
-
-