Search in sources :

Example 1 with ReplayCause

use of org.jenkinsci.plugins.workflow.cps.replay.ReplayCause in project blueocean-plugin by jenkinsci.

the class PipelineRunImpl method getChangeSet.

@Override
@Nonnull
public Container<BlueChangeSetEntry> getChangeSet() {
    // If this run is a replay then return the changesets from the original run
    ReplayCause replayCause = run.getCause(ReplayCause.class);
    if (replayCause != null) {
        Run run = this.run.getParent().getBuildByNumber(replayCause.getOriginalNumber());
        if (run == null) {
            return Containers.empty(getLink());
        }
        BlueRun blueRun = BlueRunFactory.getRun(run, parent);
        if (blueRun == null) {
            return Containers.empty(getLink());
        }
        return blueRun.getChangeSet();
    } else {
        Map<String, BlueChangeSetEntry> m = new LinkedHashMap<>();
        int cnt = 0;
        for (ChangeLogSet<? extends Entry> cs : run.getChangeSets()) {
            for (ChangeLogSet.Entry e : cs) {
                cnt++;
                String id = e.getCommitId();
                if (id == null)
                    id = String.valueOf(cnt);
                m.put(id, new ChangeSetResource(organization, e, this));
            }
        }
        return Containers.fromResourceMap(getLink(), m);
    }
}
Also used : ChangeLogSet(hudson.scm.ChangeLogSet) Entry(hudson.scm.ChangeLogSet.Entry) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) StoppableRun(io.jenkins.blueocean.service.embedded.rest.StoppableRun) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) Run(hudson.model.Run) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) BlueChangeSetEntry(io.jenkins.blueocean.rest.model.BlueChangeSetEntry) ReplayCause(org.jenkinsci.plugins.workflow.cps.replay.ReplayCause) ChangeSetResource(io.jenkins.blueocean.service.embedded.rest.ChangeSetResource) LinkedHashMap(java.util.LinkedHashMap) Nonnull(javax.annotation.Nonnull)

Aggregations

Run (hudson.model.Run)1 ChangeLogSet (hudson.scm.ChangeLogSet)1 Entry (hudson.scm.ChangeLogSet.Entry)1 BlueChangeSetEntry (io.jenkins.blueocean.rest.model.BlueChangeSetEntry)1 BlueRun (io.jenkins.blueocean.rest.model.BlueRun)1 ChangeSetResource (io.jenkins.blueocean.service.embedded.rest.ChangeSetResource)1 StoppableRun (io.jenkins.blueocean.service.embedded.rest.StoppableRun)1 LinkedHashMap (java.util.LinkedHashMap)1 Nonnull (javax.annotation.Nonnull)1 ReplayCause (org.jenkinsci.plugins.workflow.cps.replay.ReplayCause)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1