当前位置: 首页>>代码示例>>Java>>正文


Java QueueListener类代码示例

本文整理汇总了Java中hudson.model.queue.QueueListener的典型用法代码示例。如果您正苦于以下问题:Java QueueListener类的具体用法?Java QueueListener怎么用?Java QueueListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueueListener类属于hudson.model.queue包,在下文中一共展示了QueueListener类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendNotifications

import hudson.model.queue.QueueListener; //导入依赖的package包/类
/**
 * Sends notifications to Bitbucket on Checkout (for the "In Progress" Status).
 */
private static void sendNotifications(Run<?, ?> build, TaskListener listener)
        throws IOException, InterruptedException {
    final SCMSource s = SCMSource.SourceByItem.findSource(build.getParent());
    if (!(s instanceof GiteaSCMSource)) {
        return;
    }
    GiteaSCMSource source = (GiteaSCMSource) s;
    if (new GiteaSCMSourceContext(null, SCMHeadObserver.none())
            .withTraits(source.getTraits())
            .notificationsDisabled()) {
        return;
    }
    String url;
    try {
        url = DisplayURLProvider.get().getRunURL(build);
    } catch (IllegalStateException e) {
        listener.getLogger().println(
                "Can not determine Jenkins root URL. Commit status notifications are disabled until a root URL is"
                        + " configured in Jenkins global configuration.");
        return;
    }
    Result result = build.getResult();
    GiteaCommitStatus status = new GiteaCommitStatus();
    status.setTargetUrl(url);
    status.setContext(build.getParent().getFullName());
    if (Result.SUCCESS.equals(result)) {
        status.setDescription("This commit looks good");
        status.setState(GiteaCommitState.SUCCESS);
    } else if (Result.UNSTABLE.equals(result)) {
        status.setDescription("This commit has test failures");
        status.setState(GiteaCommitState.FAILURE);
    } else if (Result.FAILURE.equals(result)) {
        status.setDescription("There was a failure building this commit");
        status.setState(GiteaCommitState.FAILURE);
    } else if (result != null) { // ABORTED etc.
        status.setDescription("Something is wrong with the build of this commit");
        status.setState(GiteaCommitState.ERROR);
    } else {
        status.setDescription("Build started...");
        status.setState(GiteaCommitState.PENDING);
    }

    SCMRevision revision = SCMRevisionAction.getRevision(source, build);
    String hash;
    if (revision instanceof BranchSCMRevision) {
        listener.getLogger().format("[Gitea] Notifying branch build status: %s %s%n",
                status.getState().name(), status.getDescription());
        hash = ((BranchSCMRevision) revision).getHash();
    } else if (revision instanceof PullRequestSCMRevision) {
        listener.getLogger().format("[Gitea] Notifying pull request build status: %s %s%n",
                status.getState().name(), status.getDescription());
        hash = ((PullRequestSCMRevision) revision).getOrigin().getHash();
    } else {
        // TODO tags
        return;
    }
    JobScheduledListener jsl = ExtensionList.lookup(QueueListener.class).get(JobScheduledListener.class);
    if (jsl != null) {
        // we are setting the status, so don't let the queue listener background thread change it to pending
        synchronized (jsl.resolving) {
            jsl.resolving.remove(build.getParent());
        }
    }
    try (GiteaConnection c = source.gitea().open()) {
        c.createCommitStatus(source.getRepoOwner(), source.getRepository(), hash, status);
        listener.getLogger().format("[Gitea] Notified%n");
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:72,代码来源:GiteaNotifier.java

示例2: instance

import hudson.model.queue.QueueListener; //导入依赖的package包/类
public static ScheduledRate instance() {
    Jenkins jenkins = Jenkins.getInstance();
    return jenkins == null ? null : jenkins.getExtensionList(QueueListener.class).get(ScheduledRate.class);
}
 
开发者ID:jenkinsci,项目名称:metrics-plugin,代码行数:5,代码来源:JenkinsMetricProviderImpl.java


注:本文中的hudson.model.queue.QueueListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。