Class GitHubPRTrigger
- java.lang.Object
-
- hudson.triggers.Trigger<Job<?,?>>
-
- com.github.kostyasha.github.integration.generic.GitHubTrigger<GitHubPRTrigger>
-
- org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Trigger<?>>
public class GitHubPRTrigger extends GitHubTrigger<GitHubPRTrigger>
GitHub Pull Request trigger. Planned trigger modes: - just incoming hooks, without persist (save PR state to local xml) - hooks with persist - cron run, persistRestrictions can't have resolver, so they separate and provide security check methods: - Target branch restriction
GitHubPRUserRestriction
- User restriction (check comments, labels, etc)GitHubPRUserRestriction
(whitelist manipulations using comments is also allowed)Event triggering is modular. Now they can be split to any events: - Trigger by comment - Trigger when PR opened - Trigger when PR closed - Trigger by label - etc.
- Author:
- Kanstantsin Shautsou
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GitHubPRTrigger.DescriptorImpl
-
Nested classes/interfaces inherited from class hudson.triggers.Trigger
Trigger.Cron
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static String
FINISH_MSG
-
Fields inherited from class com.github.kostyasha.github.integration.generic.GitHubTrigger
cancelQueued, skipFirstRun
-
-
Constructor Summary
Constructors Constructor Description GitHubPRTrigger()
For groovy UIGitHubPRTrigger(String spec, GitHubPRTriggerMode triggerMode, List<GitHubPREvent> events)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
doRun()
Blocking run.void
doRun(Integer prNumber)
Runs check.GitHubPRBranchRestriction
getBranchRestriction()
GitHubPRTrigger.DescriptorImpl
getDescriptor()
List<GitHubPREvent>
getEvents()
String
getFinishMsg()
GitHubPRPollingLogAction
getPollingLogAction()
GitHubPRUserRestriction
getUserRestriction()
boolean
isPreStatus()
void
queueRun(Job<?,?> job, int prNumber)
Deprecated.Why do we need to pass job here? Trigger.start() should happen when job is configured/loaded...void
queueRun(Integer prNumber)
void
run()
non-blocking run.void
setBranchRestriction(GitHubPRBranchRestriction branchRestriction)
void
setPreStatus(boolean preStatus)
void
setUserRestriction(GitHubPRUserRestriction userRestriction)
void
start(Job<?,?> job, boolean newInstance)
-
Methods inherited from class com.github.kostyasha.github.integration.generic.GitHubTrigger
getErrorsAction, getJob, getProjectActions, getRemoteRepository, getRepoFullName, getRepoFullName, getRepoName, getRepoProvider, getRepoProviders, getTriggerMode, isAbortRunning, isCancelQueued, isSkipFirstRun, saveIfSkipFirstRun, setAbortRunning, setCancelQueued, setRepoName, setRepoProvider, setRepoProviders, setSkipFirstRun, setTriggerMode, stop, trySave
-
Methods inherited from class hudson.triggers.Trigger
all, checkTriggers, for_, getProjectAction, getSpec, readResolve, toString
-
-
-
-
Field Detail
-
FINISH_MSG
public static final String FINISH_MSG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GitHubPRTrigger
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public GitHubPRTrigger() throws ANTLRException
For groovy UI- Throws:
ANTLRException
-
GitHubPRTrigger
@DataBoundConstructor public GitHubPRTrigger(String spec, GitHubPRTriggerMode triggerMode, List<GitHubPREvent> events) throws ANTLRException
- Throws:
ANTLRException
-
-
Method Detail
-
setPreStatus
@DataBoundSetter public void setPreStatus(boolean preStatus)
-
setUserRestriction
@DataBoundSetter public void setUserRestriction(GitHubPRUserRestriction userRestriction)
-
setBranchRestriction
@DataBoundSetter public void setBranchRestriction(GitHubPRBranchRestriction branchRestriction)
-
isPreStatus
public boolean isPreStatus()
-
getEvents
@NonNull public List<GitHubPREvent> getEvents()
-
getUserRestriction
public GitHubPRUserRestriction getUserRestriction()
-
getBranchRestriction
public GitHubPRBranchRestriction getBranchRestriction()
-
start
public void start(Job<?,?> job, boolean newInstance)
- Overrides:
start
in classGitHubTrigger<GitHubPRTrigger>
-
doRun
public void doRun()
Blocking run.- Specified by:
doRun
in classGitHubTrigger<GitHubPRTrigger>
-
getPollingLogAction
@CheckForNull public GitHubPRPollingLogAction getPollingLogAction()
- Specified by:
getPollingLogAction
in classGitHubTrigger<GitHubPRTrigger>
-
getDescriptor
public GitHubPRTrigger.DescriptorImpl getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<Trigger<?>>
- Overrides:
getDescriptor
in classTrigger<Job<?,?>>
-
queueRun
@Deprecated public void queueRun(Job<?,?> job, int prNumber)
Deprecated.Why do we need to pass job here? Trigger.start() should happen when job is configured/loaded...For running from external places. Goes to queue.
-
queueRun
public void queueRun(Integer prNumber)
-
doRun
public void doRun(Integer prNumber)
Runs check. Synchronised because localRepository state is persisted after trigger decisions were made. When multiple events triggering runs in queue they triggering builds in parallel. TODO implement special queue for parallel prNumbers scans and make polling long async.- Parameters:
prNumber
- - PR number for check, if null - then all PRs
-
getFinishMsg
public String getFinishMsg()
- Specified by:
getFinishMsg
in classGitHubTrigger<GitHubPRTrigger>
-
-