Package com.groupon.jenkins.github

Examples of com.groupon.jenkins.github.GitBranch


        DynamicBuild dynamicBuild = DynamicBuildFactory.newBuild().manualStart("surya", "master").get();
        GithubRepositoryService githubRepositoryService = mock(GithubRepositoryService.class);
        when(githubRepositoryService.getShaForBranch("master")).thenReturn("masterSha");
        DynamicBuildModel model = new DynamicBuildModel(dynamicBuild, githubRepositoryService);
        model.run();
        verify(dynamicBuild).addCause(new ManualBuildCause(new GitBranch("master"), "masterSha", "surya"));
    }
View Full Code Here


    public GHContent getGHFile(String fileName, String sha) throws IOException {
        return getGithubRepository().getFileContent(fileName, sha);
    }

    public String getShaForBranch(String branch) {
        GitBranch gitBranch = new GitBranch(branch);
        if (gitBranch.isPullRequest()) {
            try {
                return getGithubRepository().getPullRequest(gitBranch.pullRequestNumber()).getHead().getSha();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        } else {
            try {
                GHRef ref = getRef("heads/" + gitBranch);
                return ref.getObject().getSha();
            } catch (IOException e) {
                return gitBranch.toString();
            }
        }
    }
View Full Code Here

    private void addBuildCauseForNonGithubCauses() {
        if (build.getCause(UserIdCause.class) != null) {
            String user = build.getCause(UserIdCause.class).getUserId();
            String branch = build.getEnvVars().get("BRANCH");
            String sha = githubRepositoryService.getShaForBranch(branch);
            ManualBuildCause manualCause = new ManualBuildCause(new GitBranch(branch), sha, user);
            build.addCause(manualCause);
        }
        if (build.getCause() == BuildCause.NULL_BUILD_CAUSE) {
            String branch = build.getEnvVars().get("BRANCH");
            String sha = githubRepositoryService.getShaForBranch(branch);
            build.addCause(new UnknownBuildCause(new GitBranch(branch), sha));
        }
    }
View Full Code Here

    public GithubCause(Payload payload, String sha) {
        this.buildDescription = payload.getBuildDescription();
        this.pusher = payload.getPusher();
        this.pullRequestNumber = payload.isPullRequest() ? payload.getPullRequestNumber() : null;
        this.sha = sha;
        this.branch = new GitBranch(payload.getBranch());
        this.logEntries = payload.getLogEntries();
    }
View Full Code Here

        return "";
    }

    @Override
    public GitBranch getBranch() {
        return new GitBranch("undetermined");
    }
View Full Code Here

TOP

Related Classes of com.groupon.jenkins.github.GitBranch

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.