hudson.triggers.SCMTrigger Java Examples

The following examples show how to use hudson.triggers.SCMTrigger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GiteaWebhookListener.java    From gitea-plugin with MIT License 6 votes vote down vote up
/**
 * {@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);
        }
    }
}
 
Example #2
Source File: BuildData.java    From jenkins-datadog-plugin with MIT License 6 votes vote down vote up
private String getUserId(Cause cause){
    if (cause instanceof TimerTrigger.TimerTriggerCause) {
        return "timer";
    } else if (cause instanceof SCMTrigger.SCMTriggerCause) {
        return "scm";
    } else if (cause instanceof Cause.UserIdCause) {
        String userName = ((Cause.UserIdCause) cause).getUserId();
        if (userName != null) {
            return userName;
        }
    } else if (cause instanceof Cause.UpstreamCause) {
        for (Cause upstreamCause : ((Cause.UpstreamCause) cause).getUpstreamCauses()) {
            String username = getUserId(upstreamCause);
            if (username != null) {
                return username;
            }
        }
    }
    return null;
}