Package co.ostorlab.ci.jenkins.plugin
Class OPlugin
- java.lang.Object
-
- hudson.tasks.BuildStepCompatibilityLayer
-
- hudson.tasks.Builder
-
- co.ostorlab.ci.jenkins.plugin.OPlugin
-
- All Implemented Interfaces:
OParameters
,ExtensionPoint
,Describable<Builder>
,BuildStep
,SimpleBuildStep
public class OPlugin extends Builder implements SimpleBuildStep, OParameters
This class defines how to upload mobile binary and retrieve scan results and overall scan risk. It would fail the job if the risk is below the user-defined threshold.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OPlugin.DescriptorImpl
Descriptor class for Build step.-
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Nested classes/interfaces inherited from interface jenkins.tasks.SimpleBuildStep
SimpleBuildStep.LastBuildAction, SimpleBuildStep.LastBuildActionFactory
-
-
Field Summary
-
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Secret
getApiKey()
Gets api key.String
getApiUrl()
Gets api url.List<Credentials>
getCredentials()
Get the list of credentials passed from the task configString
getFilePath()
Gets file name.String
getPlatform()
Gets platform.RiskInfo.RISK
getRiskThreshold()
Gets risk threshold.String
getScanProfile()
Gets scanProfile.String
getTitle()
Gets title.int
getWaitMinutes()
Gets wait minutes.boolean
isBreakBuildOnScore()
Is break build on score boolean.boolean
isWaitingForResults()
Is wait for results boolean.void
perform(Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener)
void
setApiKey(String apiKey)
Sets api key.void
setBreakBuildOnScore(boolean breakBuildOnScore)
Sets break build on score.void
setCredentials(List<Credentials> credentials)
Set the list of credentials passed from the task configvoid
setFilePath(String filePath)
Sets file name.void
setPlatform(String platform)
Sets platform.void
setScanProfile(String scanProfile)
Sets scanProfile.void
setScoreThreshold(RiskInfo.RISK riskThreshold)
Sets score threshold.void
setTitle(String title)
Sets title.void
setWaitingForResults(boolean waitForResults)
Sets wait for results.void
setWaitMinutes(int waitMinutes)
Sets wait minutes.-
Methods inherited from class hudson.tasks.Builder
all, getDescriptor, getRequiredMonitorService, prebuild
-
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectAction, getProjectActions, perform, perform, prebuild
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, getRequiredMonitorService, perform, prebuild
-
Methods inherited from interface jenkins.tasks.SimpleBuildStep
perform, perform, requiresWorkspace
-
-
-
-
Constructor Detail
-
OPlugin
@DataBoundConstructor public OPlugin(String filePath, String title, String scanProfile, String platform, boolean waitForResults, int waitMinutes, boolean breakBuildOnScore, RiskInfo.RISK riskThreshold, String apiKey, String JsonCredentials) throws com.github.cliftonlabs.json_simple.JsonException
Instantiates a new O plugin.- Parameters:
filePath
- the mobile application file pathtitle
- the scan titlescanProfile
- the scan scanProfile to useplatform
- the application platformwaitForResults
- Boolean to wait for the scan results before finishing the jobwaitMinutes
- the number of minutes to wait before resuming the jobbreakBuildOnScore
- Boolean to break build if the risk is higher than the thresholdriskThreshold
- the risk thresholdapiKey
- the API key to authenticate the requestsJsonCredentials
- the credentials in JSON format to use for the scan- Throws:
com.github.cliftonlabs.json_simple.JsonException
-
-
Method Detail
-
getApiKey
public Secret getApiKey()
Gets api key.- Returns:
- the api key
-
setApiKey
public void setApiKey(String apiKey)
Sets api key.- Parameters:
apiKey
- the api key
-
getApiUrl
public String getApiUrl()
Description copied from interface:OParameters
Gets api url.- Specified by:
getApiUrl
in interfaceOParameters
- Returns:
- the api url
-
getFilePath
@Nonnull public String getFilePath()
Description copied from interface:OParameters
Gets file name.- Specified by:
getFilePath
in interfaceOParameters
- Returns:
- the file name
-
setFilePath
@DataBoundSetter public void setFilePath(@Nonnull String filePath)
Sets file name.- Parameters:
filePath
- the file name
-
getTitle
public String getTitle()
Description copied from interface:OParameters
Gets title.- Specified by:
getTitle
in interfaceOParameters
- Returns:
- the title
-
setTitle
@DataBoundSetter public void setTitle(String title)
Sets title.- Parameters:
title
- the title
-
isWaitingForResults
public boolean isWaitingForResults()
Description copied from interface:OParameters
Is wait for results boolean.- Specified by:
isWaitingForResults
in interfaceOParameters
- Returns:
- the boolean
-
setWaitingForResults
@DataBoundSetter public void setWaitingForResults(boolean waitForResults)
Sets wait for results.- Parameters:
waitForResults
- the wait for results
-
getWaitMinutes
public int getWaitMinutes()
Description copied from interface:OParameters
Gets wait minutes.- Specified by:
getWaitMinutes
in interfaceOParameters
- Returns:
- the wait minutes
-
setWaitMinutes
@DataBoundSetter public void setWaitMinutes(int waitMinutes)
Sets wait minutes.- Parameters:
waitMinutes
- the wait minutes
-
getScanProfile
public String getScanProfile()
Description copied from interface:OParameters
Gets scanProfile.- Specified by:
getScanProfile
in interfaceOParameters
- Returns:
- the scanProfile
-
setScanProfile
@DataBoundSetter public void setScanProfile(String scanProfile)
Sets scanProfile.- Parameters:
scanProfile
- the scanProfile
-
getPlatform
public String getPlatform()
Description copied from interface:OParameters
Gets platform.- Specified by:
getPlatform
in interfaceOParameters
- Returns:
- the platform
-
setPlatform
@DataBoundSetter public void setPlatform(String platform)
Sets platform.- Parameters:
platform
- the platform
-
isBreakBuildOnScore
public boolean isBreakBuildOnScore()
Description copied from interface:OParameters
Is break build on score boolean.- Specified by:
isBreakBuildOnScore
in interfaceOParameters
- Returns:
- the boolean
-
setBreakBuildOnScore
@DataBoundSetter public void setBreakBuildOnScore(boolean breakBuildOnScore)
Sets break build on score.- Parameters:
breakBuildOnScore
- the break build on score
-
getRiskThreshold
public RiskInfo.RISK getRiskThreshold()
Description copied from interface:OParameters
Gets risk threshold.- Specified by:
getRiskThreshold
in interfaceOParameters
- Returns:
- the risk threshold
-
setScoreThreshold
@DataBoundSetter public void setScoreThreshold(RiskInfo.RISK riskThreshold)
Sets score threshold.- Parameters:
riskThreshold
- the risk threshold
-
getCredentials
public List<Credentials> getCredentials()
Get the list of credentials passed from the task config- Specified by:
getCredentials
in interfaceOParameters
- Returns:
-
setCredentials
@DataBoundSetter public void setCredentials(List<Credentials> credentials)
Set the list of credentials passed from the task config- Parameters:
credentials
-
-
perform
public void perform(Run<?,?> run, @NonNull FilePath workspace, @NonNull Launcher launcher, @NonNull TaskListener listener) throws InterruptedException, IOException
- Specified by:
perform
in interfaceSimpleBuildStep
- Throws:
InterruptedException
IOException
-
-