本文整理汇总了Java中hudson.triggers.Trigger类的典型用法代码示例。如果您正苦于以下问题:Java Trigger类的具体用法?Java Trigger怎么用?Java Trigger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Trigger类属于hudson.triggers包,在下文中一共展示了Trigger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newInstance
import hudson.triggers.Trigger; //导入依赖的package包/类
@Override
public Trigger newInstance(StaplerRequest req, @Nonnull JSONObject jsonObject) throws FormException {
if (jsonObject.has("subscribeInternalScm")) {
jsonObject.put("subscribeInternalScm", Boolean.TRUE);
}
return super.newInstance(req, jsonObject);
}
示例2: triggerFrom
import hudson.triggers.Trigger; //导入依赖的package包/类
/**
* support matrix plugin.
*
* @see JobInfoHelpers#triggerFrom(hudson.model.Job, java.lang.Class)
*/
@CheckForNull
public static <T extends Trigger> T triggerFrom(final Job<?, ?> job, Class<T> tClass) {
Job<?, ?> guessJob;
if (job instanceof MatrixConfiguration) {
guessJob = ((MatrixConfiguration) job).getParent();
} else {
guessJob = job;
}
if (guessJob instanceof AbstractProject<?, ?>) {
final AbstractProject<?, ?> abstractProject = (AbstractProject<?, ?>) guessJob;
return abstractProject.getTrigger(tClass);
} else if (guessJob instanceof ParameterizedJobMixIn.ParameterizedJob) {
ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) guessJob;
for (Trigger candidate : pJob.getTriggers().values()) {
if (tClass.isInstance(candidate)) {
return tClass.cast(candidate);
}
}
}
return null;
}
示例3: checkTriggers
import hudson.triggers.Trigger; //导入依赖的package包/类
private void checkTriggers(Calendar calendar) {
Jenkins instance = Jenkins.getInstance();
for (AbstractProject<?, ?> project : instance.getAllItems(AbstractProject.class)) {
for (Trigger<?> trigger : project.getTriggers().values()) {
if (trigger instanceof ParameterizedTimerTrigger) {
LOGGER.fine("cron checking " + project.getName());
ParameterizedTimerTrigger ptTrigger = (ParameterizedTimerTrigger) trigger;
try {
ptTrigger.checkCronTabsAndRun(calendar);
} catch (Throwable e) {
// t.run() is a plugin, and some of them throw RuntimeException and other things.
// don't let that cancel the polling activity. report and move on.
LOGGER.log(Level.WARNING,
trigger.getClass().getName() + ".run() failed for " + project.getName(), e);
}
}
}
}
}
示例4: builds
import hudson.triggers.Trigger; //导入依赖的package包/类
private BitbucketBuilds builds(Run<?, ?> r) {
BitbucketBuildTrigger trigger = null;
if (r instanceof AbstractBuild) {
trigger = BitbucketBuildTrigger.getTrigger(((AbstractBuild) r).getProject());
} else {
Job job = r.getParent();
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
for (Trigger<?> t : ((ParameterizedJobMixIn.ParameterizedJob) job).getTriggers().values()) {
if (t instanceof BitbucketBuildTrigger) {
trigger = (BitbucketBuildTrigger) t;
}
}
}
}
return trigger == null ? null : trigger.getBuilder().getBuilds();
}
开发者ID:nishio-dens,项目名称:bitbucket-pullrequest-builder-plugin,代码行数:18,代码来源:BitbucketBuildListener.java
示例5: probeJobs
import hudson.triggers.Trigger; //导入依赖的package包/类
private void probeJobs(@CheckForNull String port, List<Job> jobs) throws IOException {
for (Job<?, ?> job : jobs) {
P4Trigger trigger = null;
LOGGER.fine("P4: trying: " + job.getName());
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
ParameterizedJobMixIn.ParameterizedJob pJob = (ParameterizedJobMixIn.ParameterizedJob) job;
for (Trigger<?> t : pJob.getTriggers().values()) {
if (t instanceof P4Trigger) {
trigger = (P4Trigger) t;
break;
}
}
}
if (trigger != null) {
LOGGER.info("P4: probing: " + job.getName());
trigger.poke(job, port);
} else {
LOGGER.fine("P4: trigger not set: " + job.getName());
}
}
}
示例6: getReparentedTrigger
import hudson.triggers.Trigger; //导入依赖的package包/类
/**
* This method re-parents a given trigger, to ensure that it belongs to the
* current project.
* <p>
* It does so by looping it through XStream to get a copy and then calling
* {@link Trigger#start(Item, boolean)} on it; just like if the project was
* just read from disk.
* <p>
* As such, this method should be highly robust, but is of course very much
* slower than if it had a reliable direct copying method available.
*
* @param trigger
* @return
*/
private <T extends Trigger> T getReparentedTrigger(T trigger) {
//Copy the trigger by looping it through XSTREAM and then calling start()
//based on the CURRENT project
//TODO: Find out somehow if "trigger" already belongs to the current project
try {
String xml = Jenkins.XSTREAM2.toXML(trigger);
if (xml == null) { return trigger; }
Object copy = Jenkins.XSTREAM2.fromXML(xml);
if (copy == null || !(copy instanceof Trigger)) {
return trigger;
}
//The copying loop was successful! Calling start() on the trigger
trigger = (T) copy;
trigger.start(this, false);
return trigger;
} catch (XStreamException ex) {
//The loop-copy failed; returning the originally retrieved field
return trigger;
}
}
示例7: fixBuildTriggers
import hudson.triggers.Trigger; //导入依赖的package包/类
private static void fixBuildTriggers(AbstractProject implementationProject, Map<TriggerDescriptor, Trigger> oldTriggers) {
List<Trigger<?>> triggersToReplace = ProjectUtils.getTriggers(implementationProject);
if (triggersToReplace == null) {
throw new NullPointerException("triggersToReplace");
}
if (!triggersToReplace.isEmpty() || !oldTriggers.isEmpty()) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (triggersToReplace) {
triggersToReplace.clear();
for (Trigger trigger : oldTriggers.values()) {
triggersToReplace.add(trigger);
}
}
}
}
示例8: getTrigger
import hudson.triggers.Trigger; //导入依赖的package包/类
@CheckForNull
public static DockerHubTrigger getTrigger(ParameterizedJobMixIn.ParameterizedJob job) {
Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
DockerHubTrigger.DescriptorImpl descriptor = jenkins.getDescriptorByType(DockerHubTrigger.DescriptorImpl.class);
if (descriptor != null) {
Map<TriggerDescriptor, Trigger<?>> triggers = job.getTriggers();
return (DockerHubTrigger)triggers.get(descriptor);
}
}
return null;
}
示例9: newInstance
import hudson.triggers.Trigger; //导入依赖的package包/类
@Override
public Trigger<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
JSONObject data = formData.getJSONObject("options");
List<TriggerOption> r = new Vector<TriggerOption>();
for (TriggerOptionDescriptor d : TriggerOptionDescriptor.all()) {
String safeName = d.getJsonSafeClassName();
if (req.getParameter(safeName) != null) {
TriggerOption instance = d.newInstance(req, data.getJSONObject(safeName));
r.add(instance);
}
}
return new DockerHubTrigger(r);
}
示例10: getParameter
import hudson.triggers.Trigger; //导入依赖的package包/类
/**
* Overrides certain parameter names with certain values needed when setting the configuration for
* template projects. Otherwise, relies on the standard implementation.
* <br>
* {@inheritDoc}
*/
@Override
public String getParameter(String name) {
// Sanitize the following parameters
if ("name".equals(name)) {
// Don't set the name
return null;
} else if ("description".equals(name)) {
// Don't set the description
return null;
} else if ("disable".equals(name)) {
// Mark disabled
return "";
}
/*
* Parameters for conflicting triggers should return null if the
* corresponding JSON was not provided. Otherwise, NPEs occur when
* trying to update the triggers for the template project.
*/
DescriptorExtensionList<Trigger<?>, TriggerDescriptor> triggerDescriptors = Trigger.all();
for (TriggerDescriptor triggerDescriptor : triggerDescriptors) {
String safeName = triggerDescriptor.getJsonSafeClassName();
try {
if (name.equals(safeName) && getSubmittedForm().getJSONObject(safeName).isNullObject()) {
return null;
}
} catch (ServletException e) {
throw new IllegalStateException("Exception getting data from submitted JSON", e);
}
}
// Fallback to standard functionality
return super.getParameter(name);
}
示例11: getFromJob
import hudson.triggers.Trigger; //导入依赖的package包/类
public static GitLabPushTrigger getFromJob(Job<?, ?> job) {
GitLabPushTrigger trigger = null;
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
ParameterizedJobMixIn.ParameterizedJob p = (ParameterizedJobMixIn.ParameterizedJob) job;
for (Trigger t : p.getTriggers().values()) {
if (t instanceof GitLabPushTrigger) {
trigger = (GitLabPushTrigger) t;
}
}
}
return trigger;
}
示例12: handle
import hudson.triggers.Trigger; //导入依赖的package包/类
@Override
public void handle(Job<?, ?> job, PushHook hook, boolean ciSkip, BranchFilter branchFilter, MergeRequestLabelFilter mergeRequestLabelFilter) {
try {
if (job instanceof ParameterizedJobMixIn.ParameterizedJob) {
ParameterizedJob project = (ParameterizedJobMixIn.ParameterizedJob) job;
GitLabConnectionProperty property = job.getProperty(GitLabConnectionProperty.class);
for (Trigger t : project.getTriggers().values()) {
if (t instanceof GitLabPushTrigger) {
final GitLabPushTrigger trigger = (GitLabPushTrigger) t;
Integer projectId = hook.getProjectId();
if (property != null && property.getClient() != null && projectId != null && trigger != null) {
GitLabClient client = property.getClient();
for (MergeRequest mergeRequest : getOpenMergeRequests(client, projectId.toString())) {
if (mergeRequestLabelFilter.isMergeRequestAllowed(mergeRequest.getLabels())) {
handleMergeRequest(job, hook, ciSkip, branchFilter, client, mergeRequest);
}
}
}
}
}
} else {
LOGGER.log(Level.FINE, "Not a ParameterizedJob: {0}",LoggerUtil.toArray(job.getClass().getName()));
}
} catch (WebApplicationException | ProcessingException e) {
LOGGER.log(Level.WARNING, "Failed to communicate with gitlab server to determine if this is an update for a merge request: " + e.getMessage(), e);
}
}
示例13: getTrigger
import hudson.triggers.Trigger; //导入依赖的package包/类
public <T extends Trigger> T getTrigger(Class<T> clazz, IMode mode) {
final Class<T> fClazz = clazz;
InheritanceGovernor<T> gov =
new InheritanceGovernor<T>(
"triggers", SELECTOR.MISC, this) {
@Override
protected T castToDestinationType(Object o) {
try {
return (T) o;
} catch (ClassCastException e) {
return null;
}
}
@Override
public T getRawField(InheritanceProject ip) {
return ip.getRawTrigger(fClazz);
}
/*
@Override
protected T reduceFromFullInheritance(Deque<T> list) {
//Just select the last trigger; it will be of the correct class
return list.getLast();
}
*/
};
//Return a trigger that is guaranteed to be owned by the current project
T trigger = gov.retrieveFullyDerivedField(this, mode);
return getReparentedTrigger(trigger);
}
示例14: queryProject
import hudson.triggers.Trigger; //导入依赖的package包/类
private void queryProject(Project job, Hashtable<String, InstalledPlugin> installedPluginSet) {
if (job != null) {
// Query Builders
if (job.getBuilders() != null && job.getBuilders().size() > 0) {
for (int i = 0; i < job.getBuilders().size(); i++) {
LOG.log(Level.FINE, "getBuilders " + addJob(job.getName(), job.getShortUrl(), job.getBuilders().get(i).getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getBuilders is empty");
}
if (job.getBuildWrappersList() != null && job.getBuildWrappersList().size() > 0) {
DescribableList<BuildWrapper, Descriptor<BuildWrapper>> wrappersList = job.getBuildWrappersList();
Iterator<BuildWrapper> buildWrapperIterator = wrappersList.iterator();
while (buildWrapperIterator.hasNext()) {
BuildWrapper buildWrapper = buildWrapperIterator.next();
LOG.log(Level.FINE, "getBuildWrappers " + addJob(job.getName(), job.getShortUrl(), buildWrapper.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getBuildWrappers is empty");
}
if (job.getPublishersList() != null && job.getPublishersList().size() > 0) {
DescribableList<Publisher, Descriptor<Publisher>> publisherList = job.getPublishersList();
Iterator<Publisher> publisherIterator = publisherList.iterator();
while (publisherIterator.hasNext()) {
Publisher publisher = publisherIterator.next();
LOG.log(Level.FINE, "getPublishersList " + addJob(job.getName(), job.getShortUrl(), publisher.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getPublishersList is empty");
}
if (job.getScm() != null) {
LOG.log(Level.FINE, "getScm " + addJob(job.getName(), job.getShortUrl(), job.getScm().getClass(), installedPluginSet));
} else {
LOG.log(Level.FINE, "getScm is empty");
}
if (job.getTriggers() != null && job.getTriggers().size() > 0) {
Iterator<Trigger> triggerIterator = job.getTriggers().values().iterator();
while (triggerIterator.hasNext()) {
Trigger trigger = triggerIterator.next();
LOG.log(Level.FINE, "getTriggers " + addJob(job.getName(), job.getShortUrl(), trigger.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getTriggers is empty");
}
if (job.getProperties() !=null && job.getProperties().size() > 0){
Map<JobPropertyDescriptor,JobProperty> properties = job.getProperties();
for (Map.Entry<JobPropertyDescriptor,JobProperty> entry : properties.entrySet()) {
LOG.log(Level.FINE, "getProperties " + addJob(job.getName(), job.getShortUrl(), entry.getKey().getClass(), installedPluginSet));
}
}else {
LOG.log(Level.FINE, "getProperties is empty");
}
if (job.getAllActions() != null && job.getAllActions().size() > 0) {
for (Action action : job.getAllActions()) {
LOG.log(Level.FINE, "getAllActions " + addJob(job.getName(), job.getShortUrl(), action.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getAllActions is empty");
}
} else {
LOG.log(Level.FINE, "PROJECT is null");
}
}
示例15: queryMatrixProject
import hudson.triggers.Trigger; //导入依赖的package包/类
private void queryMatrixProject(MatrixProject job, Hashtable<String, InstalledPlugin> installedPluginSet) {
if (job != null) {
if (job.getBuilders() != null && job.getBuilders().size() > 0) {
for (int i = 0; i < job.getBuilders().size(); i++) {
LOG.log(Level.FINE, "getBuilders " + addJob(job.getName(), job.getShortUrl(), job.getBuilders().get(i).getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getBuilders is empty");
}
if (job.getBuildWrappersList() != null && job.getBuildWrappersList().size() > 0) {
DescribableList<BuildWrapper, Descriptor<BuildWrapper>> wrappersList = job.getBuildWrappersList();
Iterator<BuildWrapper> buildWrapperIterator = wrappersList.iterator();
while (buildWrapperIterator.hasNext()) {
BuildWrapper buildWrapper = buildWrapperIterator.next();
LOG.log(Level.FINE, "getBuildWrappers " + addJob(job.getName(), job.getShortUrl(), buildWrapper.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getBuildWrappers is empty");
}
if (job.getPublishersList() != null && job.getPublishersList().size() > 0) {
DescribableList<Publisher, Descriptor<Publisher>> publisherList = job.getPublishersList();
Iterator<Publisher> publisherIterator = publisherList.iterator();
while (publisherIterator.hasNext()) {
Publisher publisher = publisherIterator.next();
LOG.log(Level.FINE, "getPublishersList " + addJob(job.getName(), job.getShortUrl(), publisher.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getPublishersList is empty");
}
if (job.getScm() != null) {
LOG.log(Level.FINE, "getScm " + addJob(job.getName(), job.getShortUrl(), job.getScm().getClass(), installedPluginSet));
} else {
LOG.log(Level.FINE, "getScm is empty");
}
if (job.getTriggers() != null && job.getTriggers().size() > 0) {
Iterator<Trigger<?>> triggerIterator = job.getTriggers().values().iterator();
while (triggerIterator.hasNext()) {
Trigger trigger = triggerIterator.next();
LOG.log(Level.FINE, "getTriggers " + addJob(job.getName(), job.getShortUrl(), trigger.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getTriggers is empty");
}
// TODO: Query Properties
if (job.getProperties() !=null && job.getProperties().size() > 0){
LOG.log(Level.FINE, "getProperties is " + job.getProperties().size());
for (int j = 0; j < job.getProperties().size(); j++) {
LOG.log(Level.FINE, "getProperties " +job.getProperties().get(j));//+ /+ addJob(job, job.getProperties().get(j).getClass(), installedPluginSet));
}
}else {
LOG.log(Level.FINE, "getProperties is empty");
}
if (job.getAllActions() != null && job.getAllActions().size() > 0) {
for (Action action : job.getAllActions()) {
LOG.log(Level.FINE, "getAllActions " + addJob(job.getName(), job.getShortUrl(), action.getClass(), installedPluginSet));
}
} else {
LOG.log(Level.FINE, "getAllActions is empty");
}
} else {
LOG.log(Level.FINE, "PROJECT is null");
}
}