Package hudson.plugins.git.util

Examples of hudson.plugins.git.util.BuildData


    public GitRevisionBuildParameters() {
    }

    @Override
    public Action getAction(AbstractBuild<?, ?> build, TaskListener listener) {
        BuildData data = build.getAction(BuildData.class);
        if (data == null) {
            listener.getLogger().println("This project doesn't use Git as SCM. Can't pass the revision to downstream");
            return null;
        }

        return new RevisionParameterAction(data.getLastBuiltRevision().getSha1String());
    }
View Full Code Here


        final String internalTagComment = new StringBuilder()
            .append(GitConstants.INTERNAL_TAG_COMMENT_PREFIX)
            .append(build.getNumber()).toString();


        final BuildData buildData = getBuildData(build.getPreviousBuild(), true);

        if (buildData.lastBuild != null) {
            listener.getLogger().println("Last Built Revision: " + buildData.lastBuild.revision);
        }

        EnvVars environment = build.getEnvironment(listener);

        String confName = getGitConfigNameToUse();
        if (StringUtils.isNotBlank(confName)) {
            environment.put(GitConstants.GIT_COMMITTER_NAME_ENV_VAR, confName);
            environment.put(GitConstants.GIT_AUTHOR_NAME_ENV_VAR, confName);
        }
        String confEmail = getGitConfigEmailToUse();
        if (StringUtils.isNotBlank(confEmail)) {
            environment.put(GitConstants.GIT_COMMITTER_EMAIL_ENV_VAR, confEmail);
            environment.put(GitConstants.GIT_AUTHOR_EMAIL_ENV_VAR, confEmail);
        }

        final String singleBranch = GitUtils.getSingleBranch(build, getRepositories(), getBranches());
        final String paramLocalBranch = getParamLocalBranch(build);
        Revision tempParentLastBuiltRev = null;

        if (build instanceof MatrixRun) {
            MatrixBuild parentBuild = ((MatrixRun) build).getParentBuild();
            if (parentBuild != null) {
                BuildData parentBuildData = parentBuild.getAction(BuildData.class);
                if (parentBuildData != null) {
                    tempParentLastBuiltRev = parentBuildData.getLastBuiltRevision();
                }
            }
        }

        final List<RemoteConfig> paramRepos = getParamExpandedRepos(build);
View Full Code Here


    public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) {
        super.buildEnvVars(build, env);
        GitUtils.buildBranchEnvVar(build, env, getRepositories(), getBranches());
        BuildData bd = fixNull(getBuildData(build, false));
        if (bd != null && bd.getLastBuiltRevision() != null) {
            String commit = bd.getLastBuiltRevision().getSha1String();
            if (commit != null) {
                env.put(GIT_COMMIT, commit);
            }
        }
View Full Code Here

     * @param build build.
     * @param clone is clone.
     * @return the last recorded build data
     */
    public BuildData getBuildData(Run build, boolean clone) {
        BuildData buildData = null;
        while (build != null) {
            buildData = build.getAction(BuildData.class);
            if (buildData != null) {
                break;
            }
            build = build.getPreviousBuild();
        }

        if (buildData == null) {
            return clone ? new BuildData() : null;
        }

        if (clone) {
            return buildData.clone();
        } else {
            return buildData;
        }
    }
View Full Code Here

            // If we've never been built before, well, gotta build!
            listener.getLogger().println("[poll] No previous build, so forcing an initial build.");
            return PollingResult.BUILD_NOW;
        }

        final BuildData buildData = fixNull(getBuildData(lastBuild, false));

        if (buildData != null && buildData.lastBuild != null) {
            listener.getLogger().println("[poll] Last Built Revision: " + buildData.lastBuild.revision);
        }
View Full Code Here

        return refSpec;
    }


    private BuildData fixNull(BuildData bd) {
        return bd != null ? bd : new BuildData() /*dummy*/;
    }
View Full Code Here

                    return r;
            }
        } else {
            for (Object object : theProject.getBuilds()) {
                Build r = (Build) object;
                BuildData bd = r.getAction(BuildData.class);
                if (bd != null && bd.getLastBuiltRevision().getSha1String().equals(ref))
                    return r;
            }
        }

        return null;
View Full Code Here

            public void populate(final DirectoryRepositoryItem directory) {
                HudsonWalker.traverseProjectsAndBuilds(new HudsonVisitor()
                {
                    public void visitModuleSet(MavenModuleSetBuild run)
                    {
                        BuildData bd = run.getAction(BuildData.class);
                        if (bd != null && run.getResult() == Result.SUCCESS) {
                            String sha1 = bd.getLastBuiltRevision().getSha1String();
                            RepositoryElement content = new ProjectBuildRepositoryRoot(AllSHA1RepositoryRoot.this,run,sha1);
                            add(content, false);

                        }
                    }
View Full Code Here

            log.info("Getting builds from {}", item);

            for (Run run : item.asProject().getBuilds()) {
                try
                {
                    BuildData bd = run.getAction(BuildData.class);
                    if (bd != null && run.getResult() == Result.SUCCESS) {
                        String sha1 = bd.getLastBuiltRevision().getSha1String();

                        // Most recent, only if successful
                        if (!children.containsKey(sha1) && run.getResult().isBetterOrEqualTo(Result.SUCCESS)) {
                            children.put(sha1, new ProjectBuildRepositoryRoot(this, run, sha1));
                        }
View Full Code Here

        }

        // remove the BuildData action that we may have added earlier to avoid
        // having two of them, and because the one we added isn't correct
        // @see GhprbTrigger
        BuildData fakeOne = null;
        for (BuildData data : build.getActions(BuildData.class)) {
            if (data.getLastBuiltRevision() != null && !data.getLastBuiltRevision().getSha1String().equals(c.getCommit())) {
                fakeOne = data;
                break;
            }
View Full Code Here

TOP

Related Classes of hudson.plugins.git.util.BuildData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.