Examples of GithubRepositoryService


Examples of com.groupon.jenkins.github.services.GithubRepositoryService

public class DynamicBuildModelTest {

    @Test
    public void should_add_manual_build_cause_before_run_if_build_is_manually_kicked_off() {
        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

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

    @Test
    public void should_delete_sub_build_when_build_is_deleted() throws IOException {
        DynamicSubBuild subBuild = mock(DynamicSubBuild.class);
        DynamicBuild dynamicBuild = DynamicBuildFactory.newBuild().withSubBuilds(subBuild).get();
        GithubRepositoryService githubRepositoryService = mock(GithubRepositoryService.class);
        DynamicBuildModel model = new DynamicBuildModel(dynamicBuild, githubRepositoryService);

        model.deleteBuild();

        verify(dynamicBuild).delete();
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

        verify(subBuild).delete();
    }

    @Test
    public void should_return_null_cause_if_buildcause_has_not_been_initialized() {
        GithubRepositoryService githubRepositoryService = mock(GithubRepositoryService.class);
        DynamicBuildModel model = new DynamicBuildModel(newBuild().get(), githubRepositoryService);
        assertEquals(BuildCause.NULL_BUILD_CAUSE, model.getBuildCause());
    }
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

    @Test
    public void should_add_unknown_build_cause_if_build_kickedoff_by_an_upstream_build() {
        DynamicBuild dynamicBuild = DynamicBuildFactory.newBuild().get();
        when(dynamicBuild.getCause()).thenReturn(BuildCause.NULL_BUILD_CAUSE);
        GithubRepositoryService githubRepositoryService = mock(GithubRepositoryService.class);
        DynamicBuildModel model = new DynamicBuildModel(dynamicBuild, githubRepositoryService);
        model.run();
        ArgumentCaptor<UnknownBuildCause> argument = ArgumentCaptor.forClass(UnknownBuildCause.class);
        verify(dynamicBuild).addCause(argument.capture());
        UnknownBuildCause buildCause = argument.getValue();
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

        GithubAuthenticationToken auth = (GithubAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        return auth.getGitHub().getRepository(repoName);
    }

    public void doRefreshHook(StaplerRequest request, StaplerResponse response) throws IOException, ServletException {
        new GithubRepositoryService(getGithubRepository(request)).addHook();
        response.forwardToPreviousPage(request);
    }
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

    private final DynamicProjectRepository dynamicProjectRepository;
    private final GithubAccessTokenRepository githubAccessTokenRepository;
    private final GithubRepositoryService githubRepositoryService;

    public ProjectConfigInfo(String ghRepoName, GHRepository ghRepository) {
        this(ghRepoName, ghRepository, new DynamicProjectRepository(), new GithubAccessTokenRepository(), new GithubRepositoryService(ghRepository));
    }
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

import org.kohsuke.github.GHContent;

public class BuildConfigurationCalculator {

    public BuildConfiguration calculateBuildConfiguration(String githubRepoUrl, String sha, EnvVars envVars) throws IOException, InterruptedException, InvalidBuildConfigurationException {
        GithubRepositoryService githubRepositoryService = getGithubRepositoryService(githubRepoUrl);
        DotCiTemplate dotCiTemplate = new DotCiTemplate();
        try {
            GHContent file = githubRepositoryService.getGHFile(".ci.yml", sha);
            BuildConfiguration configuration = new BuildConfiguration(file.getContent(), envVars);
            if (!configuration.isValid()) {
                throw new InvalidBuildConfigurationException(configuration.getValidationErrors());
            }
          if(configuration.getLanguage() == null){
              DotCiTemplate defaultParentTemplate = dotCiTemplate.getDefaultFor(githubRepositoryService.getGithubRepository()); //.getBuildConfiguration(envVars);
              return dotCiTemplate.getMergedTemplate(configuration,defaultParentTemplate,envVars);
          }
            return dotCiTemplate.getMergedTemplate(configuration, configuration.getLanguage(), envVars);
        } catch (FileNotFoundException e) {
            return dotCiTemplate.getDefaultFor(githubRepositoryService.getGithubRepository()).getBuildConfiguration(envVars);
        }
    }
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

            return dotCiTemplate.getDefaultFor(githubRepositoryService.getGithubRepository()).getBuildConfiguration(envVars);
        }
    }

    protected GithubRepositoryService getGithubRepositoryService(String githubRepoUrl) {
        return new GithubRepositoryService(githubRepoUrl);
    }
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

        listener.getLogger().println("setting commit status on Github for " + repository.getUrl() + "/commit/" + sha1);

    }

    protected GHRepository getGithubRepository(DynamicBuild build) {
        return new GithubRepositoryService(build.getGithubRepoUrl()).getGithubRepository();
    }
View Full Code Here

Examples of com.groupon.jenkins.github.services.GithubRepositoryService

        branches.add("Pull Request: ");
        return branches;
    }

    GHRepository getGhRepository() {
        return new GithubRepositoryService(githubRepoUrl).getGithubRepository();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.