Class RelizaPR
- java.lang.Object
-
- hudson.tasks.BuildStepCompatibilityLayer
-
- hudson.tasks.Builder
-
- io.reliza.plugins.reliza.RelizaPR
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Builder>
,BuildStep
,SimpleBuildStep
public class RelizaPR extends Builder implements SimpleBuildStep
Method that denotes that we are sending data for a pull request.Method itself does not require parameters but requires that the Flags class passed during library initialization contains these parameters.
- apiKeyId (required) - flag for instance api id.
- apiKey (required) - flag for instance api key.
- branch (required) - flag to denote name of the base branch for the pull request.
- targetBranch (required) - flag to denote name of the target branch for the pull request.
- state (required) - flag to denote state of the pull request.
- endpoint (required) - flag to denote HTML endpoint of the pull request.
- title (required) - flag to denote title of the pull request.
- number (required) - flag to denote number of the pull request.
- commits (required) - flag to denote comma seprated commit shas on this pull request (Optional when single commit flag is used).
- commit (optional) - flag to denote current commit sha of this pull request.
- createdDate (required) - flag to denote datetime when the pull request was created.
- closedDate (optional) - flag to denote datetime when the pull request was closed.
- mergedDate (optional) - flag to denote datetime when the pull request was merged.
- projectId (optional) - flag to denote project uuid. Required if organization-wide read-write key is used, ignored if project specific api key is used.
returns true if successful API call and null otherwise.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RelizaPR.DescriptorImpl
-
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
-
-
Constructor Summary
Constructors Constructor Description RelizaPR()
Builder initialization with no required parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
perform(Run<?,?> run, FilePath workspace, EnvVars envVars, Launcher launcher, TaskListener listener)
Extracts project details from environment variables to send release metadata to reliza hub.static String
resolveEnvVar(String envVar, String suffix, EnvVars envVars)
Obtains env variable with envSuffix if it exists, otherwise obtains env variable without envSuffix.void
setbaseBranch(String baseBranch)
Optional parameter for builder initialization.void
setClosedDate(String closedDate)
Optional parameter for builder initialization.void
setCommit(String commit)
Sets up optional parameters from buildwrapper initialization.void
setCommits(String commits)
Sets up optional parameters from buildwrapper initialization.void
setCreatedDate(String createdDate)
Optional parameter for builder initialization.void
setEndpoint(String endpoint)
Optional parameter for builder initialization.void
setEnvSuffix(String envSuffix)
Sets up optional parameters from buildwrapper initialization.void
setMergedDate(String mergedDate)
Optional parameter for builder initialization.void
setNumber(String number)
Optional parameter for builder initialization.void
setProjectId(String projectId)
Optional parameter for builder initialization.void
setState(String state)
Optional parameter for builder initialization.void
setTargetBranch(String targetBranch)
Optional parameter for builder initialization.void
settitle(String title)
Optional parameter for builder initialization.void
setUri(String uri)
Optional parameter for builder initialization.static UUID
toUUID(String projectId, TaskListener listener)
String to UUID converter which handles conversion errors.-
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
-
-
-
-
Method Detail
-
setTargetBranch
@DataBoundSetter public void setTargetBranch(String targetBranch)
Optional parameter for builder initialization.- Parameters:
targetBranch
- - Used set the targetBranch.
-
setbaseBranch
@DataBoundSetter public void setbaseBranch(String baseBranch)
Optional parameter for builder initialization.- Parameters:
baseBranch
- - Used set the baseBranch.
-
setState
@DataBoundSetter public void setState(String state)
Optional parameter for builder initialization.- Parameters:
state
- - Used to override given state if needed.
-
setEndpoint
@DataBoundSetter public void setEndpoint(String endpoint)
Optional parameter for builder initialization.- Parameters:
endpoint
- - Used to set the HTML endpoint of the PullRequest
-
settitle
@DataBoundSetter public void settitle(String title)
Optional parameter for builder initialization.- Parameters:
title
- - Used to set the title of the PullRequest
-
setNumber
@DataBoundSetter public void setNumber(String number)
Optional parameter for builder initialization.- Parameters:
number
- - Used to set the title of the PullRequest
-
setProjectId
@DataBoundSetter public void setProjectId(String projectId)
Optional parameter for builder initialization.- Parameters:
projectId
- - UUID of project, only used when supplying custom version.
-
setUri
@DataBoundSetter public void setUri(String uri)
Optional parameter for builder initialization.- Parameters:
uri
- - Base uri of api call, only used when supplying custom version. Default set to "https://app.relizahub.com".
-
setMergedDate
@DataBoundSetter public void setMergedDate(String mergedDate)
Optional parameter for builder initialization.- Parameters:
mergedDate
- - Used to set the datetime when the pull request was merged
-
setClosedDate
@DataBoundSetter public void setClosedDate(String closedDate)
Optional parameter for builder initialization.- Parameters:
closedDate
- - Used to set the datetime when the pull request was closed
-
setCreatedDate
@DataBoundSetter public void setCreatedDate(String createdDate)
Optional parameter for builder initialization.- Parameters:
createdDate
- - Used to set the datetime when the pull request was created
-
setCommits
@DataBoundSetter public void setCommits(String commits)
Sets up optional parameters from buildwrapper initialization.- Parameters:
commits
- - comma seprated commit shas on the pull request
-
setCommit
@DataBoundSetter public void setCommit(String commit)
Sets up optional parameters from buildwrapper initialization.- Parameters:
commit
- - current commit sha of the pull request
-
setEnvSuffix
@DataBoundSetter public void setEnvSuffix(String envSuffix)
Sets up optional parameters from buildwrapper initialization.- Parameters:
envSuffix
- - Flag which adds a suffix to all environment variables to differentiate from other withReliza calls.
-
perform
public void perform(Run<?,?> run, FilePath workspace, EnvVars envVars, Launcher launcher, TaskListener listener) throws InterruptedException, IOException
Extracts project details from environment variables to send release metadata to reliza hub.- Specified by:
perform
in interfaceSimpleBuildStep
- Throws:
InterruptedException
IOException
-
toUUID
public static UUID toUUID(String projectId, TaskListener listener)
String to UUID converter which handles conversion errors.- Parameters:
projectId
- - Project UUID.listener
- - TaskListener to log specific error.- Returns:
- Corresponding UUID if conversion succeeded and null otherwise.
-
resolveEnvVar
public static String resolveEnvVar(String envVar, String suffix, EnvVars envVars)
Obtains env variable with envSuffix if it exists, otherwise obtains env variable without envSuffix. If neither exist null is passed through.- Parameters:
envVar
- - Key to resolve to a value using environment variablessuffix
- - Search for environment variables with this suffixenvVars
- - Map of all environment variables to search through- Returns:
- Corresponding value from environment variable map
-
-