jenkins.plugins.git.GitSampleRepoRule Java Examples
The following examples show how to use
jenkins.plugins.git.GitSampleRepoRule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 5 votes |
protected void loadSourceCodeInGitRepository(GitSampleRepoRule gitRepo, String name) throws Exception { gitRepo.init(); Path mavenProjectRoot = Paths.get(WithMavenStepOnMasterTest.class.getResource(name).toURI()); if (!Files.exists(mavenProjectRoot)) { throw new IllegalStateException("Folder '" + mavenProjectRoot + "' not found"); } GitSampleRepoRuleUtils.addFilesAndCommit(mavenProjectRoot, gitRepo); }
Example #2
Source File: PipelineRunImplTest.java From blueocean-plugin with MIT License | 5 votes |
private void updateREADME(GitSampleRepoRule sampleRepo) throws Exception { updateREADMECounter++; sampleRepo.write("README.md", "README + " + updateREADMECounter + ":" + sampleRepo.toString()); sampleRepo.git("add", "README.md"); sampleRepo.git("commit", "--all", "--message=README + " + updateREADMECounter + ":" + sampleRepo.toString()); }
Example #3
Source File: JobAnalyticsTest.java From blueocean-plugin with MIT License | 5 votes |
private void createMultiBranch(GitSampleRepoRule rule) throws Exception { WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, UUID.randomUUID().toString()); mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, rule.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0]))); mp.save(); mp.scheduleBuild2(0).getFuture().get(); mp.getIndexing().getLogText().writeLogTo(0, System.out); j.waitUntilNoActivity(); WorkflowJob master = mp.getItemByBranchName("master"); assertNotNull(master); WorkflowRun lastBuild = master.getLastBuild(); assertNotNull(lastBuild); assertEquals(Result.SUCCESS, lastBuild.getResult()); }
Example #4
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenJarWithJacocoInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_jar_with_jacoco_project/"); }
Example #5
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadNbmDependencyMavenJarProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_nbm_dependency_project/"); }
Example #6
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadNbmBaseMavenProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_nbm_base_project/"); }
Example #7
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMultiModuleProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_maven_project/"); }
Example #8
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadJenkinsPluginProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_hpi_project/"); }
Example #9
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenPluginProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_plugin_project/"); }
Example #10
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadOsgiBundleProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/multi_module_bundle_project/"); }
Example #11
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenJarWithFlattenPomProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_jar_with_flatten_pom_project/"); }
Example #12
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenWarProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_war_project/"); }
Example #13
Source File: GitReadSaveTest.java From blueocean-plugin with MIT License | 4 votes |
private void testGitReadWrite(final @Nonnull GitReadSaveService.ReadSaveType type, @Nonnull GitSampleRepoRule repo, @Nullable String startPipelineScript) throws Exception { testGitReadWrite(type, repo.getRoot().getCanonicalPath(), repo, startPipelineScript); }
Example #14
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenJarWithParentPomProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_jar_with_parent_pom_project/"); }
Example #15
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenPomProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_pom_project/"); }
Example #16
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMavenJarProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/maven_jar_project/"); }
Example #17
Source File: AbstractIntegrationTest.java From pipeline-maven-plugin with MIT License | 4 votes |
protected void loadMonoDependencyMavenProjectInGitRepo(GitSampleRepoRule gitRepo) throws Exception { loadSourceCodeInGitRepository(gitRepo, "/org/jenkinsci/plugins/pipeline/maven/test/test_maven_projects/mono_dependency_maven_jar_project/"); }
Example #18
Source File: GitReadSaveTest.java From blueocean-plugin with MIT License | 4 votes |
private void testGitReadWrite(final @Nonnull GitReadSaveService.ReadSaveType type, @Nonnull String remote, @Nonnull GitSampleRepoRule repo, @Nullable String startPipelineScript, @Nullable User user) throws Exception { GitReadSaveService.setType(type); String jobName = repo.getRoot().getName(); Map r = new RequestBuilder(baseUrl) .status(201) .jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())) .crumb( crumb ) .post("/organizations/" + getOrgName() + "/pipelines/") .data(ImmutableMap.of( "name", jobName, "$class", "io.jenkins.blueocean.blueocean_git_pipeline.GitPipelineCreateRequest", "scmConfig", ImmutableMap.of( "uri", remote, "credentialId", UserSSHKeyManager.getOrCreate(user).getId()) )).build(Map.class); assertEquals(jobName, r.get("name")); String urlJobPrefix = "/organizations/" + getOrgName() + "/pipelines/" + jobName; r = new RequestBuilder(baseUrl) .status(200) .jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())) .crumb( crumb ) .get(urlJobPrefix + "/scm/content/?branch=master&path=Jenkinsfile&type="+type.name()) .build(Map.class); String base64Data = (String)((Map)r.get("content")).get("base64Data"); assertEquals(startPipelineScript, base64Data == null ? null : new String(Base64.decode(base64Data), "utf-8")); // Update the remote String newBase64Data = Base64.encode(newPipelineScript.getBytes("utf-8")); Map<String,String> content = new HashMap<>(); content.put("message", "Save Jenkinsfile"); content.put("path", "Jenkinsfile"); content.put("branch", "master"); content.put("sourceBranch", "master"); content.put("repo", jobName); // if no repo, this is not in an org folder content.put("sha", ""); content.put("base64Data", newBase64Data); content.put("type", type.name()); new RequestBuilder(baseUrl) .status(200) .jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())) .crumb( crumb ) .put(urlJobPrefix + "/scm/content/") .data(ImmutableMap.of("content", content)) .build(Map.class); // Check to make sure the remote was actually updated: // refs udpated in our sample repo, not working tree, update it to get contents: repo.git("reset", "--hard", "refs/heads/master"); String remoteJenkinsfile = FileUtils.readFileToString(new File(repo.getRoot(), "Jenkinsfile")); Assert.assertEquals(newPipelineScript, remoteJenkinsfile); // check to make sure we get the same thing from the service r = new RequestBuilder(baseUrl) .status(200) .crumb( crumb ) .jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())) .get(urlJobPrefix + "/scm/content/?branch=master&path=Jenkinsfile&type="+type.name()) .build(Map.class); base64Data = (String)((Map)r.get("content")).get("base64Data"); Assert.assertEquals(base64Data, newBase64Data); }
Example #19
Source File: GitReadSaveTest.java From blueocean-plugin with MIT License | 4 votes |
private void testGitReadWrite(final @Nonnull GitReadSaveService.ReadSaveType type, @Nonnull String remote, @Nonnull GitSampleRepoRule repo, @Nullable String startPipelineScript) throws Exception { testGitReadWrite(type,remote,repo,startPipelineScript, login()); }