Java源码示例:hudson.scm.SCMRevisionState

示例1
@Override
public SCMRevisionState calcRevisionsFromBuild(Run<?, ?> build,
        FilePath workspace, Launcher launcher, TaskListener listener)
        throws IOException, InterruptedException {
    EnvVars env = build.getEnvironment(listener);
    listener.getLogger().println(
            String.format(MessageConstants.SCM_CALC, DISPLAY_NAME,
                    getImageStreamName(env), tag, getNamespace(env)));

    String commitId = lastCommitId;

    ImageStreamRevisionState currIMSState = null;
    if (commitId != null) {
        currIMSState = new ImageStreamRevisionState(commitId);
        listener.getLogger().println(
                String.format(MessageConstants.SCM_LAST_REV,
                        currIMSState.toString()));
    } else {
        currIMSState = new ImageStreamRevisionState("");
        listener.getLogger().println(MessageConstants.SCM_NO_REV);
    }

    return currIMSState;
}
 
示例2
@Override
public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener,
    File changelogFile,
    SCMRevisionState pollingBaseline) {
    LOGGER.log(Level.FINE, String.format("SCMListener: Checkout > %s", build.getFullDisplayName()));
    sendNotifications(build, listener);
}
 
示例3
@Override
public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener, File changelogFile,
                       SCMRevisionState pollingBaseline) throws Exception {
    try {
        sendNotifications(build, listener);
    } catch (IOException | InterruptedException e) {
        e.printStackTrace(listener.error("Could not send notifications"));
    }
}
 
示例4
@Override
public void checkout(Run<?,?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException {
    listener.getLogger().println("Staging "+path);
    OutputStream os = workspace.child(path).write();
    IOUtils.write(contents, os);
    os.close();
}
 
示例5
@Override
public void checkout(Run<?, ?> build, Launcher launcher,
        FilePath workspace, TaskListener listener, File changelogFile,
        SCMRevisionState baseline) throws IOException, InterruptedException {
    boolean chatty = Boolean.parseBoolean(verbose);

    String bldName = null;
    if (build != null)
        bldName = build.getDisplayName();
    if (chatty)
        listener.getLogger().println(
                "\n\nOpenShiftImageStreams checkout called for " + bldName);

    EnvVars env = build.getEnvironment(listener);
    lastCommitId = getCommitId(listener, env);
    if (lastCommitId == null) {
        String imageStream = getImageStreamName(env);
        String tag = getTag(env);
        listener.getLogger().println(
                String.format(MessageConstants.SCM_IMAGESTREAM_NOT_FOUND,
                        imageStream, tag));
        // We cannot yet throw an exception here because the calling code
        // will be interrupted and the SCM action
        // will not be added to the build job.
        // Just setting the build result here. An exception will be thrown
        // in the postCheckout method.
        build.setResult(Result.FAILURE);
    }
}
 
示例6
protected PollingResult compareRemoteRevisionInternal(EnvVars env,
        Launcher launcher, TaskListener listener, SCMRevisionState baseline) {
    listener.getLogger().println(
            String.format(MessageConstants.SCM_COMP, DISPLAY_NAME,
                    getImageStreamName(env), tag, getNamespace(env)));
    String commitId = this.getCommitId(listener, env);

    ImageStreamRevisionState currIMSState = null;
    if (commitId != null)
        currIMSState = new ImageStreamRevisionState(commitId);
    boolean chatty = Boolean.parseBoolean(verbose);
    if (chatty)
        listener.getLogger().println(
                "\n\nOpenShiftImageStreams compareRemoteRevisionWith comparing baseline "
                        + baseline + " with lastest " + currIMSState);
    boolean changes = false;
    if (baseline != null && baseline instanceof ImageStreamRevisionState
            && currIMSState != null)
        changes = !currIMSState.equals(baseline);

    if (baseline == null && currIMSState != null) {
        changes = true;
    }

    if (changes) {
        lastCommitId = commitId;
        listener.getLogger().println(MessageConstants.SCM_CHANGE);
    } else {
        listener.getLogger().println(MessageConstants.SCM_NO_CHANGE);
    }

    return new PollingResult(baseline, currIMSState,
            changes ? Change.SIGNIFICANT : Change.NONE);
}
 
示例7
@Override
public PollingResult compareRemoteRevisionWith(@Nonnull Job<?, ?> project,
        @Nullable Launcher launcher, @Nullable FilePath workspace,
        @Nonnull TaskListener listener, @Nonnull SCMRevisionState baseline)
        throws IOException, InterruptedException {
    return compareRemoteRevisionInternal(
            project.getEnvironment(null, listener), launcher, listener,
            baseline);
}
 
示例8
@Override
protected PollingResult compareRemoteRevisionWith(
        AbstractProject<?, ?> project, Launcher launcher,
        FilePath workspace, TaskListener listener, SCMRevisionState baseline)
        throws IOException, InterruptedException {
    return compareRemoteRevisionInternal(
            project.getEnvironment(null, listener), launcher, listener,
            baseline);
}
 
示例9
@Override
protected PollingResult compareRemoteRevisionWith(
        final AbstractProject<?, ?> project,
        final Launcher launcher,
        final FilePath filePath,
        final TaskListener listener,
        final SCMRevisionState revisionState)
        throws IOException, InterruptedException {

    final ActionTypeId actionTypeId = new ActionTypeId()
            .withCategory(actionTypeCategory)
            .withOwner(ActionOwner.Custom)
            .withProvider(actionTypeProvider)
            .withVersion(actionTypeVersion);

    final String projectName = Validation.sanitize(project.getName().trim());

    LoggingHelper.log(listener, "Polling for jobs for action type id: ["
            + "Owner: %s, Category: %s, Provider: %s, Version: %s, ProjectName: %s]",
            actionTypeId.getOwner(),
            actionTypeId.getCategory(),
            actionTypeId.getProvider(),
            actionTypeId.getVersion(),
            project.getName());

    return pollForJobs(projectName, actionTypeId, listener);
}
 
示例10
@Override
public SCMRevisionState calcRevisionsFromBuild(
        final AbstractBuild<?, ?> build,
        final Launcher launcher,
        final TaskListener taskListener)
        throws IOException, InterruptedException {
    return null;
}
 
示例11
@Override
public void checkout(Run<?, ?> build, Launcher launcher, FilePath remoteDir, TaskListener listener, File changeLogFile, SCMRevisionState baseline) throws IOException, InterruptedException {
    new FilePath(changeLogFile).touch(0);
    build.addAction(new ChangelogAction(entries, changeLogFile.getName()));
    entries = new ArrayList<EntryImpl>();
}
 
示例12
@Override
public void onCheckout(Run<?, ?> build, SCM scm, FilePath workspace, TaskListener listener, File changelogFile,
                       SCMRevisionState pollingBaseline) throws Exception {
    createBuildCommitStatus(build, listener);
}
 
示例13
@Override
public void checkout(Run<?, ?> build, Launcher launcher, FilePath workspace, TaskListener listener,
                     File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException {
    listener.getLogger().println("No SCM checkout.");
}