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


Java SCMTrigger类代码示例

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


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

示例1: onChange

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void onChange(Saveable o, XmlFile file) {
    if (!(o instanceof Item)) {
        // must be an Item
        return;
    }
    SCMTriggerItem item = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem((Item) o);
    if (item == null) {
        // more specifically must be an SCMTriggerItem
        return;
    }
    SCMTrigger trigger = item.getSCMTrigger();
    if (trigger == null || trigger.isIgnorePostCommitHooks()) {
        // must have the trigger enabled and not opted out of post commit hooks
        return;
    }
    for (SCM scm : item.getSCMs()) {
        if (scm instanceof GitSCM) {
            // we have a winner
            GiteaWebhookListener.register(item, (GitSCM) scm);
        }
    }
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:27,代码来源:GiteaWebhookListener.java

示例2: started

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
public void started(AbstractBuild build) {



        CauseAction causeAction = build.getAction(CauseAction.class);

        if (causeAction != null) {
            Cause scmCause = causeAction.findCause(SCMTrigger.SCMTriggerCause.class);
            if (scmCause == null) {
                MessageBuilder message = new MessageBuilder(notifier, build);
                message.append(causeAction.getShortDescription());
                notifyStart(build, message.appendOpenLink().toString());
                // Cause was found, exit early to prevent double-message
                return;
            }
        }

        String changes = getChanges(build, notifier.includeCustomMessage());
        if (changes != null) {
            notifyStart(build, changes);
        } else {
            notifyStart(build, getBuildStatusMessage(build, false, false,notifier.includeCustomMessage()));
        }
    }
 
开发者ID:FluffyFairyGames,项目名称:jenkins-telegram-plugin,代码行数:25,代码来源:ActiveNotifier.java

示例3: started

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
public void started(AbstractBuild build) {

		//AbstractProject<?, ?> project = build.getProject();

		CauseAction causeAction = build.getAction(CauseAction.class);

		if (causeAction != null) {
			Cause scmCause = causeAction.findCause(SCMTrigger.SCMTriggerCause.class);
			if (scmCause == null) {
				MessageBuilder message = new MessageBuilder(notifier, build);
				message.append(causeAction.getShortDescription());
				notifyStart(build, message.appendOpenLink().toString());
				// Cause was found, exit early to prevent double-message
				return;
			}
		}

		String changes = getChanges(build, notifier.includeCustomAttachmentMessage());
		if (changes != null) {
			notifyStart(build, changes);
		} else {
			notifyStart(build, getBuildStatusMessage(build, false, notifier.includeCustomAttachmentMessage()));
		}
	}
 
开发者ID:jovandeginste,项目名称:jenkins-mattermost-plugin,代码行数:25,代码来源:ActiveNotifier.java

示例4: isSkipScan

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
private boolean isSkipScan(final Run<?, ?> run) {

        if (!isSkipSCMTriggers()) {
            return false;
        }

        final List<Cause> causes = run.getCauses();
        final List<Cause> allowedCauses = new LinkedList<>();

        for (Cause c : causes) {
            if (!(c instanceof SCMTrigger.SCMTriggerCause)) {
                allowedCauses.add(c);
            }
        }
        return allowedCauses.isEmpty();
    }
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:17,代码来源:CxScanBuilder.java

示例5: testGetTriggeredByMultipleSCMChange

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
@Test
@Issue("JENKINS-22611")
public void testGetTriggeredByMultipleSCMChange() throws Exception {
    FreeStyleProject project = jenkins.createFreeStyleProject("build");
    FakeRepositoryBrowserSCM scm = new FakeRepositoryBrowserSCM();
    scm.addChange().withAuthor("test-user").withMsg("Fixed bug");
    project.setScm(scm);
    jenkins.setQuietPeriod(0);
    CauseAction action = new CauseAction(new SCMTrigger.SCMTriggerCause(""));
    action.getCauses().add(new SCMTrigger.SCMTriggerCause(""));
    action.getCauses().add(new SCMTrigger.SCMTriggerCause(""));
    action.getCauses().add(new SCMTrigger.SCMTriggerCause(""));


    project.scheduleBuild(0, null, action);
    jenkins.waitUntilNoActivity();
    List<TriggerCause> triggeredBy = TriggerCause.getTriggeredBy(project, project.getLastBuild());
    assertEquals(1, triggeredBy.size());
    assertEquals(TriggerCause.TYPE_SCM, triggeredBy.iterator().next().getType());
}
 
开发者ID:Diabol,项目名称:delivery-pipeline-plugin,代码行数:21,代码来源:TriggerCauseTest.java

示例6: getTriggerName

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
@CheckForNull
@SuppressWarnings(value = "deprecation")
static String getTriggerName(Cause cause) {
    if (SCMTrigger.SCMTriggerCause.class.isInstance(cause)) {
        return "SCMTRIGGER";
    } else if (TimerTrigger.TimerTriggerCause.class.isInstance(cause)) {
        return "TIMERTRIGGER";
    } else if (Cause.UserIdCause.class.isInstance(cause)) {
        return "MANUALTRIGGER";
    } else if (Cause.UserCause.class.isInstance(cause)) {
        return "MANUALTRIGGER";
    } else if (Cause.UpstreamCause.class.isInstance(cause)) {
        return "UPSTREAMTRIGGER";
    } else if (cause != null) {
        return cause.getClass().getSimpleName().toUpperCase(Locale.ENGLISH);
    }

    return null;
}
 
开发者ID:jenkinsci,项目名称:envinject-api-plugin,代码行数:20,代码来源:CauseHelper.java

示例7: triggerProject

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
public static void triggerProject(AbstractProject<?, ?> project) throws Exception {
    project.getTriggers().clear();
    SCMTrigger scmTrigger = new SCMTrigger("@daily", true);
    project.addTrigger(scmTrigger);
    scmTrigger.start(project, true);
    scmTrigger.new Runner().run();
}
 
开发者ID:Praqma,项目名称:pretested-integration-plugin,代码行数:8,代码来源:TestUtilsFactory.java

示例8: getUserRunTheBuild

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
public static String getUserRunTheBuild(Run build) {

        // If build has been triggered form an upstream build, get UserCause from there to set user build variables
        Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) build.getCause(Cause.UpstreamCause.class);
        if (upstreamCause != null) {
            Job job = Jenkins.getInstance().getItemByFullName(upstreamCause.getUpstreamProject(), Job.class);
            if (job != null) {
                Run upstream = job.getBuildByNumber(upstreamCause.getUpstreamBuild());
                if (upstream != null) {
                    getUserRunTheBuild(upstream);
                }
            }
        }

        // set BUILD_USER_NAME to fixed value if the build was triggered by a change in the scm
        SCMTrigger.SCMTriggerCause scmTriggerCause = (SCMTrigger.SCMTriggerCause) build.getCause(SCMTrigger.SCMTriggerCause.class);
        if (scmTriggerCause != null) {
            return SCM_TRIGGER;
        }

        // Use UserIdCause.class if it exists in the system (should be starting from b1.427 of jenkins).
        if (isClassExists(USER_ID_CAUSE_CLASS_NAME)) {
            /* Try to use UserIdCause to get & set jenkins user build variables */
            Cause.UserIdCause userIdCause = (Cause.UserIdCause) build.getCause(Cause.UserIdCause.class);
            if (userIdCause != null) {
                return userIdCause.getUserId();
            }
        }

        // Try to use deprecated UserCause to get & set jenkins user build variables
        Cause.UserCause userCause = (Cause.UserCause) build.getCause(Cause.UserCause.class);
        if (userCause != null) {
            return userCause.getUserName();
        }

        return "unknown";
    }
 
开发者ID:epicforce,项目名称:leroy_jenkins,代码行数:38,代码来源:LeroyUtils.java

示例9: isSkip

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
/**
 * Determine if the build should be skipped or not
 */
private boolean isSkip(final Run<?, ?> build, final TaskListener listener) {
    boolean skip = false;

    // Determine if the OWASP_DC_SKIP environment variable is set to true
    try {
        skip = Boolean.parseBoolean(build.getEnvironment(listener).get("OWASP_DC_SKIP"));
    } catch (Exception e) { /* throw it away */ }


    // Why was this build triggered? Get the causes and find out.
    @SuppressWarnings("unchecked")
    final List<Cause> causes = build.getCauses();
    for (Cause cause: causes) {
        // Skip if the build is configured to skip on SCM change and the cause of the build was an SCM trigger
        if (skipOnScmChange && cause instanceof SCMTrigger.SCMTriggerCause) {
            skip = true;
        }
        // Skip if the build is configured to skip on Upstream change and the cause of the build was an Upstream trigger
        if (skipOnUpstreamChange && cause instanceof Cause.UpstreamCause) {
            skip = true;
        }
    }

    // Log a message if being skipped
    if (skip) {
        listener.getLogger().println(OUT_TAG + "Skipping Dependency-Check analysis.");
    }

    return skip;
}
 
开发者ID:jenkinsci,项目名称:dependency-check-plugin,代码行数:34,代码来源:AbstractDependencyCheckBuilder.java

示例10: resolveCause

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
@Override
public TriggerCause resolveCause(Cause cause) {
    if (cause instanceof Cause.UserIdCause) {
        return new TriggerCause(TriggerCause.TYPE_MANUAL, "user "
                + getDisplayName(((Cause.UserIdCause) cause).getUserName()));
    } else if (cause instanceof Cause.RemoteCause) {
        return new TriggerCause(TriggerCause.TYPE_REMOTE, "remote trigger");
    } else if (cause instanceof Cause.UpstreamCause) {
        Cause.UpstreamCause upstreamCause = (Cause.UpstreamCause) cause;
        AbstractProject upstreamProject = JenkinsUtil.getInstance().getItem(upstreamCause.getUpstreamProject(),
                JenkinsUtil.getInstance(), AbstractProject.class);
        StringBuilder causeString = new StringBuilder("upstream project");
        if (upstreamProject != null) {

            causeString.append(" ").append(upstreamProject.getDisplayName());
            AbstractBuild upstreamBuild = upstreamProject.getBuildByNumber(upstreamCause.getUpstreamBuild());
            if (upstreamBuild != null) {
                causeString.append(" build ").append(upstreamBuild.getDisplayName());
            }
        }
        return new TriggerCause(TriggerCause.TYPE_UPSTREAM, causeString.toString());
    } else if (cause instanceof Cause.UpstreamCause.DeeplyNestedUpstreamCause) {
        return new TriggerCause(TriggerCause.TYPE_UPSTREAM, "upstream");
    } else if (cause instanceof SCMTrigger.SCMTriggerCause) {
        return new TriggerCause(TriggerCause.TYPE_SCM, "SCM");
    } else if (cause instanceof TimerTrigger.TimerTriggerCause) {
        return new TriggerCause(TriggerCause.TYPE_TIMER, "timer");
    } else {
        return null;
    }
}
 
开发者ID:Diabol,项目名称:delivery-pipeline-plugin,代码行数:32,代码来源:CoreCauseResolver.java

示例11: testGetTriggeredBySCMChange

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
@Test
public void testGetTriggeredBySCMChange() throws Exception {
    FreeStyleProject project = jenkins.createFreeStyleProject("build");
    FakeRepositoryBrowserSCM scm = new FakeRepositoryBrowserSCM();
    scm.addChange().withAuthor("test-user").withMsg("Fixed bug");
    project.setScm(scm);
    jenkins.setQuietPeriod(0);
    project.scheduleBuild(new SCMTrigger.SCMTriggerCause("SCM"));
    jenkins.waitUntilNoActivity();
    List<TriggerCause> triggeredBy = TriggerCause.getTriggeredBy(project, project.getLastBuild());
    assertEquals(1, triggeredBy.size());
    assertEquals(TriggerCause.TYPE_SCM, triggeredBy.iterator().next().getType());
}
 
开发者ID:Diabol,项目名称:delivery-pipeline-plugin,代码行数:14,代码来源:TriggerCauseTest.java

示例12: testGetTriggeredBySCMChangeQueued

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
@Test
public void testGetTriggeredBySCMChangeQueued() throws Exception {
    FreeStyleProject project = jenkins.createFreeStyleProject("build");
    FakeRepositoryBrowserSCM scm = new FakeRepositoryBrowserSCM();
    scm.addChange().withAuthor("test-user").withMsg("Fixed bug");
    project.setScm(scm);
    jenkins.setQuietPeriod(0);
    jenkins.getInstance().setNumExecutors(0);
    project.scheduleBuild(0, new SCMTrigger.SCMTriggerCause("SCM"));
    //jenkins.waitUntilNoActivity();
    List<TriggerCause> triggeredBy = TriggerCause.getTriggeredBy(project, null);
    assertEquals(1, triggeredBy.size());
    assertEquals(TriggerCause.TYPE_SCM, triggeredBy.iterator().next().getType());
}
 
开发者ID:Diabol,项目名称:delivery-pipeline-plugin,代码行数:15,代码来源:TriggerCauseTest.java

示例13: executeCheck

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
public boolean executeCheck(Item item) {
    if (item instanceof AbstractProject) {
        return (((AbstractProject) item).getTrigger(SCMTrigger.class) != null);
    }
    return false;
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:7,代码来源:PollingSCMTriggerChecker.java

示例14: testTriggerSCMJob

import hudson.triggers.SCMTrigger; //导入依赖的package包/类
@Test public void testTriggerSCMJob() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject();
    project.addTrigger(new SCMTrigger("", true));
    assertTrue(checker.executeCheck(project));
}
 
开发者ID:v1v,项目名称:jenkinslint-plugin,代码行数:6,代码来源:PollingSCMTriggerCheckerTestCase.java


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