jenkins.scm.api.mixin.ChangeRequestSCMRevision Java Examples

The following examples show how to use jenkins.scm.api.mixin.ChangeRequestSCMRevision. 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: ChangeRequestBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Restricted(ProtectedExternally.class)
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision lastBuiltRevision, @CheckForNull SCMRevision lastSeenRevision, @NonNull TaskListener listener) {
    if (!(head instanceof ChangeRequestSCMHead)) {
        return false;
    }
    if (ignoreTargetOnlyChanges
            && currRevision instanceof ChangeRequestSCMRevision
            && lastBuiltRevision instanceof ChangeRequestSCMRevision) {
        ChangeRequestSCMRevision<?> curr = (ChangeRequestSCMRevision<?>) currRevision;
        if (curr.isMerge() && curr.equivalent((ChangeRequestSCMRevision<?>) lastBuiltRevision)) {
            return false;
        }
    }
    try {
        if (ignoreUntrustedChanges && !currRevision.equals(source.getTrustedRevision(currRevision, listener))) {
            return false;
        }
    } catch (IOException | InterruptedException e) {
        LogRecord lr = new LogRecord(Level.WARNING,
                "Could not determine trust status for revision {0} of {1}, assuming untrusted");
        lr.setParameters(new Object[] {currRevision, head});
        lr.setThrown(e);
        Functions.printLogRecord(lr);
        return false;
    }
    return true;
}
 
Example #2
Source File: ChangeSCMRevision.java    From gerrit-code-review-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equivalent(ChangeRequestSCMRevision<?> o) {
  if (!(o instanceof ChangeSCMRevision)) {
    return false;
  }
  ChangeSCMRevision other = (ChangeSCMRevision) o;

  // Force a rebuild, if the job building this change already exists, but has a pending checks.
  // Only used, if the FilterChecksTrait is used.
  if (isFilteredByPendingChecks) {
    return false;
  }

  return getHead().equals(other.getHead()) && patchsetHash.equals(other.patchsetHash);
}
 
Example #3
Source File: PullRequestSCMRevision.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Override
public boolean equivalent(ChangeRequestSCMRevision<?> o) {
    if (!(o instanceof PullRequestSCMRevision)) {
        return false;
    }
    PullRequestSCMRevision other = (PullRequestSCMRevision) o;

    // JENKINS-57583 - Equivalent is used to make decisions about when to build.
    // mergeHash is an implementation detail of github, generated from base and target
    // If only mergeHash changes we do not consider it a different revision
    return getHead().equals(other.getHead()) && pullHash.equals(other.pullHash);
}
 
Example #4
Source File: MergeRequestSCMRevision.java    From gitlab-branch-source-plugin with MIT License 4 votes vote down vote up
@Override
public boolean equivalent(ChangeRequestSCMRevision<?> revision) {
    return (revision instanceof MergeRequestSCMRevision)
        && origin.equals(((MergeRequestSCMRevision) revision).getOrigin());
}
 
Example #5
Source File: PullRequestSCMRevision.java    From gitea-plugin with MIT License 4 votes vote down vote up
@Override
public boolean equivalent(ChangeRequestSCMRevision<?> revision) {
    return (revision instanceof PullRequestSCMRevision)
            && origin.equals(((PullRequestSCMRevision) revision).getOrigin());
}