Java Code Examples for jenkins.triggers.SCMTriggerItem#getSCMs()

The following examples show how to use jenkins.triggers.SCMTriggerItem#getSCMs() . 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: HistoryAggregatedFlakyTestResultAction.java    From flaky-test-handler-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a SingleTestFlakyStatsWithRevision object with {@link SingleTestFlakyStats} and
 * build information.
 *
 * @param stats Embedded {@link SingleTestFlakyStats} object
 * @param build The {@link hudson.model.Run} object to get SCM information from.
 */
public SingleTestFlakyStatsWithRevision(SingleTestFlakyStats stats, Run build) {
  this.stats = stats;
  revision = Integer.toString(build.getNumber());

  Job job = build.getParent();
  SCMTriggerItem s = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(job);
  if (s != null) {
    ArrayList<SCM> scms = new ArrayList<>(s.getSCMs());
    SCM scm = scms.size() > 0 ? scms.get(0) : null;

    if (scm != null && "hudson.plugins.git.GitSCM".equalsIgnoreCase(scm.getType())) {
      GitSCM gitSCM = (GitSCM) scm;
      BuildData buildData = gitSCM.getBuildData(build);
      if (buildData != null) {
        Revision gitRevision = buildData.getLastBuiltRevision();
        if (gitRevision != null) {
          revision = gitRevision.getSha1String();
        }
      }
    }
  }
}
 
Example 3
Source File: BuildStatusAction.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private boolean hasGitSCM(SCMTriggerItem item) {
    if (item != null) {
        for (SCM scm : item.getSCMs()) {
            if (scm instanceof GitSCM) {
                return true;
            }
        }
    }
    return false;
}
 
Example 4
Source File: AbstractWebHookTriggerHandler.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private GitSCM getGitSCM(SCMTriggerItem item) {
    if (item != null) {
        for (SCM scm : item.getSCMs()) {
            if (scm instanceof GitSCM) {
                return (GitSCM) scm;
            }
        }
    }
    return null;
}
 
Example 5
Source File: ProjectLabelsProvider.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private GitSCM getGitSCM(SCMTriggerItem item) {
    if (item != null) {
        for (SCM scm : item.getSCMs()) {
            if (scm instanceof GitSCM) {
                return (GitSCM) scm;
            }
        }
    }
    return null;
}
 
Example 6
Source File: ProjectBranchesProvider.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private GitSCM getGitSCM(SCMTriggerItem item) {
    if (item != null) {
        for (SCM scm : item.getSCMs()) {
            if (scm instanceof GitSCM) {
                return (GitSCM) scm;
            }
        }
    }
    return null;
}