Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RebuildDispatcher extension point to allow other plugins to propa… #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bjacklyn
Copy link

…gate additional actions to the rebuild

@bjacklyn
Copy link
Author

Inspiration from comments in this PR.

This change allows me to create a RebuildDispatcher and add the RevisionParameterAction (from the git-plugin). The dispatcher needs to be able to add new Actions because the original build does not necessarily have a RevisionParameterAction itself, so only copying actions is insufficient.

Git plugin impl:

@Extension
public class GitPluginRebuildDispatcher extends RebuildActionDispatcher {

    @Override
    public Collection<Action> getPropagatingActions(Run run) {
        List<Action> actions = Lists.newArrayList();

        BuildData buildData = run.getAction(BuildData.class);
        if (buildData != null) {

            Build build = buildData.lastBuild;
            if (build != null) {
                Revision revision = build.marked;
                if (revision == null) {
                    revision = build.revision;
                }

                if (revision != null) {
                    // Don't let the git plugin revert the BuildData of these branch(es) to this revision.
                    // Otherwise the git plugin will also rebuild the HEAD of all of these branches on the next SCM poll (yuck).
                    Revision revisionWithoutBranches = new Revision(revision.getSha1(), Collections.<Branch>emptyList());

                    actions.add(new RevisionParameterAction(revisionWithoutBranches));
                }
            }
        }

        return actions;
    }
}

<repository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org/content/repositories/releases</url>
</repository>
</repositories>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These pom changes don't seem to be necessary for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants