本文整理汇总了Java中hudson.model.FreeStyleBuild.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java FreeStyleBuild.getResult方法的具体用法?Java FreeStyleBuild.getResult怎么用?Java FreeStyleBuild.getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.model.FreeStyleBuild
的用法示例。
在下文中一共展示了FreeStyleBuild.getResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: oneInvalidFeatureBranch_1BuildIsTriggeredNothingGetsIntegratedBuildMarkedAsFAILURE
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
public void oneInvalidFeatureBranch_1BuildIsTriggeredNothingGetsIntegratedBuildMarkedAsFAILURE() throws Exception {
Repository repository = TestUtilsFactory.createRepositoryWithMergeConflict("test-repo");
repositories.add(repository);
final int COMMIT_COUNT_BEFORE_EXECUTION = TestUtilsFactory.countCommits(repository);
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, STRATEGY_TYPE.SQUASH, repository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
int nextBuildNumber = project.getNextBuildNumber();
FreeStyleBuild build = project.getBuildByNumber(nextBuildNumber - 1);
Result result = build.getResult();
assertTrue(result.isCompleteBuild());
assertTrue(result.isWorseOrEqualTo(Result.FAILURE));
final int COMMIT_COUNT_AFTER_EXECUTION = TestUtilsFactory.countCommits(repository);
TestCase.assertEquals("Commit count missmatch.", COMMIT_COUNT_AFTER_EXECUTION, COMMIT_COUNT_BEFORE_EXECUTION);
}
示例2: twoFeatureBranchesBothValid_2BuildsAreTriggeredBothBranchesGetIntegratedBuildMarkedAsSUCCESS
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
public void twoFeatureBranchesBothValid_2BuildsAreTriggeredBothBranchesGetIntegratedBuildMarkedAsSUCCESS() throws Exception {
Repository repository = TestUtilsFactory.createValidRepositoryWith2FeatureBranches("test-repo");
repositories.add(repository);
final int COMMIT_COUNT_BEFORE_EXECUTION = TestUtilsFactory.countCommits(repository);
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, STRATEGY_TYPE.SQUASH, repository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
assertEquals(2, project.getNextBuildNumber() - 1);
for (FreeStyleBuild build : builds) {
Result result = build.getResult();
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
}
final int COMMIT_COUNT_AFTER_EXECUTION = TestUtilsFactory.countCommits(repository);
TestCase.assertEquals("Commit count missmatch.", COMMIT_COUNT_AFTER_EXECUTION, COMMIT_COUNT_BEFORE_EXECUTION + 2);
}
示例3: runSquashCommitStrategyOnRepository1
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
@Ignore
public void runSquashCommitStrategyOnRepository1() throws Exception {
createValidRepositories();
String repo1Url = "file://" + repository1.getDirectory().getAbsolutePath();
FreeStyleProject project = configurePretestedIntegrationPlugin(new SquashCommitStrategy(), repo1Url);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
FreeStyleBuild build = project.getBuildByNumber(project.getNextBuildNumber() - 1);
Result result = build.getResult();
//Show the log for the latest build
String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
assertFalse(TestUtilsFactory.branchExists(repository1, READY_BRANCH_1));
assertTrue(TestUtilsFactory.branchExists(repository1, READY_BRANCH_2));
}
示例4: runSquashCommitStrategyOnRepository2
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
@Ignore
public void runSquashCommitStrategyOnRepository2() throws Exception {
createValidRepositories();
String repo2Url = "file://" + repository2.getDirectory().getAbsolutePath();
FreeStyleProject project = configurePretestedIntegrationPlugin(new SquashCommitStrategy(), repo2Url);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
FreeStyleBuild build = project.getBuildByNumber(project.getNextBuildNumber() - 1);
Result result = build.getResult();
//Show the log for the latest build
String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
assertFalse(TestUtilsFactory.branchExists(repository2, READY_BRANCH_1));
assertTrue(TestUtilsFactory.branchExists(repository2, READY_BRANCH_2));
}
示例5: runAccumulatedCommitStrategyOnRepository1
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
@Ignore
public void runAccumulatedCommitStrategyOnRepository1() throws Exception {
createValidRepositories();
String repo1Url = "file://" + repository1.getDirectory().getAbsolutePath();
FreeStyleProject project = configurePretestedIntegrationPlugin(new AccumulatedCommitStrategy(), repo1Url);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
FreeStyleBuild build = project.getBuildByNumber(project.getNextBuildNumber() - 1);
Result result = build.getResult();
//Show the log for the latest build
String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
assertFalse(TestUtilsFactory.branchExists(repository1, READY_BRANCH_1));
assertTrue(TestUtilsFactory.branchExists(repository1, READY_BRANCH_2));
}
示例6: testNoParametersBuild
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
public void testNoParametersBuild() throws Exception {
addBuildStep();
FreeStyleBuild build = p.scheduleBuild2(0).get();
Result result = build.getResult();
assertSuccessfulBuild(result);
}
示例7: oneValidFeatureBranch_1BuildIsTriggeredTheBranchGetsIntegratedBuildMarkedAsSUCCESS
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
public void oneValidFeatureBranch_1BuildIsTriggeredTheBranchGetsIntegratedBuildMarkedAsSUCCESS() throws Exception {
String repoName = "test-repo";
Repository repository = TestUtilsFactory.createValidRepository(repoName);
repositories.add(repository);
File workDir = new File(TestUtilsFactory.WORKDIR, repoName);
Git.cloneRepository().setURI("file:///" + repository.getDirectory().getAbsolutePath()).setDirectory(workDir)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();
String readmeFromDev = FileUtils.readFileToString(new File(workDir,"readme"));
final int COMMIT_COUNT_BEFORE_EXECUTION = TestUtilsFactory.countCommits(workDir);
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, STRATEGY_TYPE.SQUASH, repository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
int nextBuildNumber = project.getNextBuildNumber();
FreeStyleBuild build = project.getBuildByNumber(nextBuildNumber - 1);
Result result = build.getResult();
assertTrue(result.isCompleteBuild());
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
String readmeFileContents = FileUtils.readFileToString(new File(workDir,"readme"));
assertEquals(readmeFromDev, readmeFileContents);
final int COMMIT_COUNT_AFTER_EXECUTION = TestUtilsFactory.countCommits(repository);
TestCase.assertEquals("Commit count missmatch.", COMMIT_COUNT_AFTER_EXECUTION, COMMIT_COUNT_BEFORE_EXECUTION + 1);
}
示例8: oneValidFeatureBranchRunningOnSlave_1BuildIsTriggeredTheBranchGetsIntegratedBuildMarkedAsSUCCESS
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
public void oneValidFeatureBranchRunningOnSlave_1BuildIsTriggeredTheBranchGetsIntegratedBuildMarkedAsSUCCESS() throws Exception {
String repoName = "test-repo";
Repository repository = TestUtilsFactory.createValidRepository(repoName);
repositories.add(repository);
File workDir = new File(TestUtilsFactory.WORKDIR, repoName);
Git.cloneRepository().setURI("file:///" + repository.getDirectory().getAbsolutePath()).setDirectory(workDir)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();
String readmeFromDev = FileUtils.readFileToString(new File(TestUtilsFactory.WORKDIR,repoName + "/readme"));
final int COMMIT_COUNT_BEFORE_EXECUTION = TestUtilsFactory.countCommits(workDir);
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, STRATEGY_TYPE.SQUASH, repository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
int nextBuildNumber = project.getNextBuildNumber();
FreeStyleBuild build = project.getBuildByNumber(nextBuildNumber - 1);
Result result = build.getResult();
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
String readmeFileContents = FileUtils.readFileToString(new File(workDir, "readme"));
assertEquals(readmeFromDev, readmeFileContents);
final int COMMIT_COUNT_AFTER_EXECUTION = TestUtilsFactory.countCommits(repository);
TestCase.assertEquals("Commit count missmatch.", COMMIT_COUNT_AFTER_EXECUTION, COMMIT_COUNT_BEFORE_EXECUTION + 1);
}
示例9: runAccumulatedCommitStrategyOnRepository2
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
@Test
@Ignore
public void runAccumulatedCommitStrategyOnRepository2() throws Exception {
createValidRepositories();
String repo2Url = "file://" + repository2.getDirectory().getAbsolutePath();
FreeStyleProject project = configurePretestedIntegrationPlugin(new AccumulatedCommitStrategy(), repo2Url);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
FreeStyleBuild build = project.getBuildByNumber(project.getNextBuildNumber() - 1);
Result result = build.getResult();
//Show the log for the latest build
String text = jenkinsRule.createWebClient().getPage(build, "console").asText();
System.out.println("=====BUILD-LOG=====");
System.out.println(text);
System.out.println("=====BUILD-LOG=====");
assertTrue(result.isCompleteBuild());
assertTrue(result.isBetterOrEqualTo(Result.SUCCESS));
assertFalse(TestUtilsFactory.branchExists(repository2, READY_BRANCH_1));
assertTrue(TestUtilsFactory.branchExists(repository2, READY_BRANCH_2));
}
示例10: commitMessagesWithDoubleQuotesSquashedLinux
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
/**
* Tests commit message with double quotes in commit message can be
* integrated using squashed strategy and a repository created on Linux. See
* detailed description of test in class documentation.
* <p>
* Uses the StaticGitRepositoryTestBase and the setUp method there, so a
* bareRepository and gitRepo is already available.
*
* @throws Exception
*/
@Test
public void commitMessagesWithDoubleQuotesSquashedLinux() throws Exception {
/**
* ********************************************************************
* Run test with Jenkins job trying to integrate the feature branch
* ********************************************************************
*/
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, bareRepository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
for (FreeStyleBuild b : builds) {
assertTrue("Could not match console output for pretty printing", TestUtilsFactory.printAndReturnConsoleOfBuild(b, String.format("%s", b.getNumber()), jenkinsRule));
Result result = b.getResult();
assertNotNull("Build result was null.", result);
assertTrue("Build was not a success - that is expected in this test", result.isBetterOrEqualTo(Result.SUCCESS));
}
/**
* ********************************************************************
* Verify integration in different aspect like commit message content
* and actual commits
* ********************************************************************
*/
// Verify number of commits - first count on master after integration
gitrepo.checkout().setName("master").call();
gitrepo.checkout().setName("master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
gitrepo.pull().call();
int commitsOnMasterAfterIntegration = TestUtilsFactory.countCommitsOnBranch(gitrepo, "master");
// Squash commit ends on master, and there is one to start with:
assertEquals(2, commitsOnMasterAfterIntegration);
// This will "walk" over the log, but we only take the first entry
// which will be the integration commit
RevWalk walk = new RevWalk(gitrepo.getRepository());
Iterable<RevCommit> log = gitrepo.log().call();
Iterator<RevCommit> i = log.iterator();
RevCommit commit = walk.parseCommit(i.next());
String commitFullMessage = commit.getFullMessage();
gitrepo.close();
System.out.println("************************************************************************");
System.out.println("* Integration commit message (between the ---):");
System.out.println("---");
System.out.println(commitFullMessage);
System.out.println("---");
System.out.println("************************************************************************");
assertTrue("The integration commit message was not a squashed commit. Didn't find the text 'Squashed commit of the following:'", commitFullMessage.contains("Squashed commit of the following:"));
assertTrue("The integration commit message, doesn't contain the SHA from the git log from the first of the included commits", commitFullMessage.contains("commit 57807c99bea0fa0f929bd32973ff9651f7c0fb04"));
assertFalse("The integration commit message, doesn't contain lines from the original commits as expected.", commitFullMessage.contains("This is a commit message with double quotes, eg. \"test quotes\"."));
//assertTrue("The integration commit message, didn't contain expected date string from the git log from the first of the included commits", commitFullMessage.contains("Tue Mar 31 16:13:30 2015 +0200"));
assertTrue("The integration commit message, didn't contain expected author string from the git log from the first of the included commits", commitFullMessage.contains("Author: Praqma Support <[email protected]>"));
assertFalse("The last commit on integration branch contain 'accumulated' but is not an accumulated commit", commitFullMessage.contains("ccumulated"));
System.out.println(String.format("***** phew... last verification (asserts) passed :-)"));
}
示例11: commitMessagesWithDoubleQuotesAccumulatedLinux
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
/**
* Tests commit message with double quotes in commit message can be
* integrated using accumulated strategy and a repository created on Linux.
* See detailed description of test in class documentation.
* <p>
* Uses the StaticGitRepositoryTestBase and the setUp method there, so a
* bareRepository and gitRepo is already available.
*
* @throws Exception
*/
@Test
public void commitMessagesWithDoubleQuotesAccumulatedLinux() throws Exception {
/**
* ********************************************************************
* Run test with Jenkins job trying to integrate the feature branch
* ********************************************************************
*/
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.ACCUMULATED, bareRepository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
for (FreeStyleBuild b : builds) {
assertTrue("Could not match console output for pretty printing", TestUtilsFactory.printAndReturnConsoleOfBuild(b, String.format("%s", b.getNumber()), jenkinsRule));
Result result = b.getResult();
assertNotNull("Build result was null.", result);
assertTrue("Build was not a success - that is expected in this test", result.isBetterOrEqualTo(Result.SUCCESS));
}
/**
* ********************************************************************
* Verify integration in different aspect like commit message content
* and actual commits
* ********************************************************************
*/
// Verify number of commits - first count on master after integration
gitrepo.checkout().setName("master").call();
gitrepo.checkout().setName("master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
gitrepo.pull().call();
int commitsOnMasterAfterIntegration = TestUtilsFactory.countCommitsOnBranch(gitrepo, "master");
// All commits end on master, and there is a merge commit
assertEquals(4, commitsOnMasterAfterIntegration);
// This will "walk" over the log, but we only take the first entry
// which will be the integration commit
RevWalk walk = new RevWalk(gitrepo.getRepository());
Iterable<RevCommit> log = gitrepo.log().call();
Iterator<RevCommit> i = log.iterator();
RevCommit commit = walk.parseCommit(i.next());
String commitFullMessage = commit.getFullMessage();
gitrepo.close();
System.out.println("************************************************************************");
System.out.println("* Integration commit message (between the ---):");
System.out.println("---");
System.out.println(commitFullMessage);
System.out.println("---");
System.out.println("************************************************************************");
assertTrue("The integration commit message was not an accumulated commit. Didn't find the text 'Accumulated commit'", commitFullMessage.contains("Accumulated commit of the following from branch 'origin/ready/JENKINS-27662_doublequotes':"));
assertTrue("The integration commit message doesn't contain the SHA from the git log from the first of the included commits", commitFullMessage.contains("commit 57807c99bea0fa0f929bd32973ff9651f7c0fb04"));
assertTrue("The integration commit message doesn't contain lines from the original commits as expected.", commitFullMessage.contains("This is a commit message with double quotes, eg. 'test quotes'."));
//assertTrue("The integration commit message, didn't contain expected date string from the git log from the first of the included commits", commitFullMessage.contains("Tue Mar 31 16:13:30 2015 +0200"));
assertTrue("The integration commit message, didn't contain expected author string from the git log from the first of the included commits", commitFullMessage.contains("Author: Praqma Support <[email protected]>"));
assertFalse("The last commit on integration branch contain 'squash' but is not a squash commit", commitFullMessage.contains("squash"));
System.out.println(String.format("***** phew... last verification (asserts) passed :-)"));
}
示例12: commitMessagesWithDoubleQuotesSquashedWindows
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
/**
* Tests commit message with double quotes in commit message can be
* integrated using squashed strategy and a repository created on Windows.
* See detailed description of test in class documentation.
* <p>
* Uses the StaticGitRepositoryTestBase and the setUp method there, so a
* bareRepository and gitRepo is already available.
*
* @throws Exception
*/
@Test
public void commitMessagesWithDoubleQuotesSquashedWindows() throws Exception {
/**
* ********************************************************************
* Run test with Jenkins job trying to integrate the feature branch
* ********************************************************************
*/
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, bareRepository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
for (FreeStyleBuild b : builds) {
assertTrue("Could not match console output for pretty printing", TestUtilsFactory.printAndReturnConsoleOfBuild(b, String.format("%s", b.getNumber()), jenkinsRule));
Result result = b.getResult();
assertNotNull("Build result was null.", result);
assertTrue("Build was not a success - that is expected in this test", result.isBetterOrEqualTo(Result.SUCCESS));
}
/**
* ********************************************************************
* Verify integration in different aspect like commit message content
* and actual commits
* ********************************************************************
*/
// Verify number of commits - first count on master after integration
gitrepo.checkout().setName("master").call();
gitrepo.checkout().setName("master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
gitrepo.pull().call();
int commitsOnMasterAfterIntegration = TestUtilsFactory.countCommitsOnBranch(gitrepo, "master");
// All commits end on master, and there is a merge commit
assertEquals(2, commitsOnMasterAfterIntegration);
// This will "walk" over the log, but we only take the first entry
// which will be the integration commit
RevWalk walk = new RevWalk(gitrepo.getRepository());
Iterable<RevCommit> log = gitrepo.log().call();
Iterator<RevCommit> i = log.iterator();
RevCommit commit = walk.parseCommit(i.next());
String commitFullMessage = commit.getFullMessage();
gitrepo.close();
System.out.println("************************************************************************");
System.out.println("* Integration commit message (between the ---):");
System.out.println("---");
System.out.println(commitFullMessage);
System.out.println("---");
System.out.println("************************************************************************");
assertTrue("The integration commit message was not a squashed commit. Didn't find the text 'Squashed commit of the following:'", commitFullMessage.contains("Squashed commit of the following:"));
assertTrue("The integration commit message, doesn't contain the SHA from the git log from the first of the included commits", commitFullMessage.contains("commit fa90cb266c4f737a09ad4a3308ec4fb5b898b9d6"));
assertFalse("The integration commit message, doesn't contain lines from the original commits as expected.", commitFullMessage.contains("This is a commit message with double quotes (commit made on Windows), eg. \"test quotes\"."));
//assertTrue("The integration commit message, didn't contain expected date string from the git log from the first of the included commits", commitFullMessage.contains("Tue Mar 31 16:08:22 2015 +0200"));
assertTrue("The integration commit message, didn't contain expected author string from the git log from the first of the included commits", commitFullMessage.contains("Author: Praqma Support <[email protected]>"));
assertFalse("The last commit on integration branch contain 'accumulated' but is not an accumulated commit", commitFullMessage.contains("ccumulated"));
System.out.println(String.format("***** phew... last verification (asserts) passed :-)"));
}
示例13: commitMessagesWithDoubleQuotesAccumulatedWindows
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
/**
* Tests commit message with double quotes in commit message can be
* integrated using accumulated strategy and a repository created on
* Windows. See detailed description of test in class documentation.
* <p>
* Uses the StaticGitRepositoryTestBase and the setUp method there, so a
* bareRepository and gitRepo is already available.
*
* @throws Exception
*/
@Test
public void commitMessagesWithDoubleQuotesAccumulatedWindows() throws Exception {
/**
* ********************************************************************
* Run test with Jenkins job trying to integrate the feature branch
* ********************************************************************
*/
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.ACCUMULATED, bareRepository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
for (FreeStyleBuild b : builds) {
assertTrue("Could not match console output for pretty printing", TestUtilsFactory.printAndReturnConsoleOfBuild(b, String.format("%s", b.getNumber()), jenkinsRule));
Result result = b.getResult();
assertNotNull("Build result was null.", result);
assertTrue("Build was not a success - that is expected in this test", result.isBetterOrEqualTo(Result.SUCCESS));
}
/**
* ********************************************************************
* Verify integration in different aspect like commit message content
* and actual commits
* ********************************************************************
*/
// Verify number of commits - first count on master after integration
gitrepo.checkout().setName("master").call();
gitrepo.checkout().setName("master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
gitrepo.pull().call();
int commitsOnMasterAfterIntegration = TestUtilsFactory.countCommitsOnBranch(gitrepo, "master");
// All commits end on master, and there is a merge commit
assertEquals(4, commitsOnMasterAfterIntegration);
// This will "walk" over the log, but we only take the first entry
// which will be the integration commit
RevWalk walk = new RevWalk(gitrepo.getRepository());
Iterable<RevCommit> log = gitrepo.log().call();
Iterator<RevCommit> i = log.iterator();
RevCommit commit = walk.parseCommit(i.next());
String commitFullMessage = commit.getFullMessage();
gitrepo.close();
System.out.println("************************************************************************");
System.out.println("* Integration commit message (between the ---):");
System.out.println("---");
System.out.println(commitFullMessage);
System.out.println("---");
System.out.println("************************************************************************");
assertTrue("The integration commit message was not an accumulated commit. Didn't find the text 'Accumulated commit'", commitFullMessage.contains("Accumulated commit of the following from branch 'origin/ready/JENKINS-27662_doublequotes':"));
assertTrue("The integration commit message doesn't contain the SHA from the git log from the first of the included commits", commitFullMessage.contains("commit fa90cb266c4f737a09ad4a3308ec4fb5b898b9d6"));
assertTrue("The integration commit message doesn't contain lines from the original commits as expected.", commitFullMessage.contains("This is a commit message with double quotes (commit made on Windows), eg. 'test quotes'."));
//assertTrue("The integration commit message, didn't contain expected date string from the git log from the first of the included commits", commitFullMessage.contains("Tue Mar 31 16:08:22 2015 +0200"));
assertTrue("The integration commit message, didn't contain expected author string from the git log from the first of the included commits", commitFullMessage.contains("Author: Praqma Support <[email protected]>"));
assertFalse("The last commit on integration branch contain 'squash' but is not a squash commit", commitFullMessage.contains("squash"));
System.out.println(String.format("***** phew... last verification (asserts) passed :-)"));
}
示例14: commitMessagesWithDoubleQuotesSingleQuotesMadeWindowsAccumulated
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
/**
* Tests commit message with double quotes, created in a script using single
* quotes can be integrated using accumulated strategy. Repository created
* on Windows. See detailed description of test in class documentation.
* <p>
* Uses the StaticGitRepositoryTestBase and the setUp method there, so a
* bareRepository and gitRepo is already available.
*
* @throws Exception
*/
@Test
public void commitMessagesWithDoubleQuotesSingleQuotesMadeWindowsAccumulated() throws Exception {
/**
* ********************************************************************
* Run test with Jenkins job trying to integrate the feature branch
* ********************************************************************
*/
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.ACCUMULATED, bareRepository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
for (FreeStyleBuild b : builds) {
assertTrue("Could not match console output for pretty printing", TestUtilsFactory.printAndReturnConsoleOfBuild(b, String.format("%s", b.getNumber()), jenkinsRule));
Result result = b.getResult();
assertNotNull("Build result was null.", result);
assertTrue("Build was not a success - that is expected in this test", result.isBetterOrEqualTo(Result.SUCCESS));
}
/**
* ********************************************************************
* Verify integration in different aspect like commit message content
* and actual commits
* ********************************************************************
*/
// Verify number of commits - first count on master after integration
gitrepo.checkout().setName("master").call();
gitrepo.checkout().setName("master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
gitrepo.pull().call();
int commitsOnMasterAfterIntegration = TestUtilsFactory.countCommitsOnBranch(gitrepo, "master");
// All commits end on master, and there is a merge commit
assertEquals(4, commitsOnMasterAfterIntegration);
// This will "walk" over the log, but we only take the first entry
// which will be the integration commit
RevWalk walk = new RevWalk(gitrepo.getRepository());
Iterable<RevCommit> log = gitrepo.log().call();
Iterator<RevCommit> i = log.iterator();
RevCommit commit = walk.parseCommit(i.next());
String commitFullMessage = commit.getFullMessage();
gitrepo.close();
System.out.println("************************************************************************");
System.out.println("* Integration commit message (between the ---):");
System.out.println("---");
System.out.println(commitFullMessage);
System.out.println("---");
System.out.println("************************************************************************");
assertTrue("The integration commit message was not an accumulated commit. Didn't find the text 'Accumulated commit'", commitFullMessage.contains("Accumulated commit of the following from branch 'origin/ready/JENKINS-27662_doublequotes':"));
assertTrue("The integration commit message, doesn't contain the SHA from the git log from the first of the included commits", commitFullMessage.contains("commit a094a8a6e8157b386b651d61997de25cd95af5eb"));
assertTrue("The integration commit message, doesn't contain lines from the original commits as expected.", commitFullMessage.contains("This is a commit message with double quotes (commit made on Windows), and =, eg. 'test quotes'."));
//assertTrue("The integration commit message, didn't contain expected date string from the git log from the first of the included commits", commitFullMessage.contains("Wed Jun 3 09:14:28 2015 +0200"));
assertTrue("The integration commit message, didn't contain expected author string from the git log from the first of the included commits", commitFullMessage.contains("Author: Praqma Support <[email protected]>"));
assertFalse("The last commit on integration branch contain 'squash' but is not a squash commit", commitFullMessage.contains("squash"));
System.out.println(String.format("***** phew... last verification (asserts) passed :-)"));
}
示例15: commitMessagesWithDoubleQuotesSingleQuotesMadeWindowsSquashed
import hudson.model.FreeStyleBuild; //导入方法依赖的package包/类
/**
* Tests commit message with double quotes, created in a script using single
* quotes can be integrated using squash strategy. Repository created on
* Windows. See detailed description of test in class documentation.
* <p>
* Uses the StaticGitRepositoryTestBase and the setUp method there, so a
* bareRepository and gitRepo is already available.
*
* @throws Exception
*/
@Test
public void commitMessagesWithDoubleQuotesSingleQuotesMadeWindowsSquashed() throws Exception {
/**
* ********************************************************************
* Run test with Jenkins job trying to integrate the feature branch
* ********************************************************************
*/
FreeStyleProject project = TestUtilsFactory.configurePretestedIntegrationPlugin(jenkinsRule, TestUtilsFactory.STRATEGY_TYPE.SQUASH, bareRepository);
TestUtilsFactory.triggerProject(project);
jenkinsRule.waitUntilNoActivityUpTo(60000);
RunList<FreeStyleBuild> builds = project.getBuilds();
for (FreeStyleBuild b : builds) {
assertTrue("Could not match console output for pretty printing", TestUtilsFactory.printAndReturnConsoleOfBuild(b, String.format("%s", b.getNumber()), jenkinsRule));
Result result = b.getResult();
assertNotNull("Build result was null.", result);
assertTrue("Build was not a success - that is expected in this test", result.isBetterOrEqualTo(Result.SUCCESS));
}
/**
* ********************************************************************
* Verify integration in different aspect like commit message content
* and actual commits
* ********************************************************************
*/
// Verify number of commits - first count on master after integration
gitrepo.checkout().setName("master").call();
gitrepo.checkout().setName("master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
gitrepo.pull().call();
int commitsOnMasterAfterIntegration = TestUtilsFactory.countCommitsOnBranch(gitrepo, "master");
// All commits end on master, and there is a merge commit
assertEquals(2, commitsOnMasterAfterIntegration);
// This will "walk" over the log, but we only take the first entry
// which will be the integration commit
RevWalk walk = new RevWalk(gitrepo.getRepository());
Iterable<RevCommit> log = gitrepo.log().call();
Iterator<RevCommit> i = log.iterator();
RevCommit commit = walk.parseCommit(i.next());
String commitFullMessage = commit.getFullMessage();
gitrepo.close();
System.out.println("************************************************************************");
System.out.println("* Integration commit message (between the ---):");
System.out.println("---");
System.out.println(commitFullMessage);
System.out.println("---");
System.out.println("************************************************************************");
assertTrue("The integration commit message was not a squashed commit. Didn't find the text 'Squashed commit of the following:'", commitFullMessage.contains("Squashed commit of the following:"));
assertTrue("The integration commit message, doesn't contain the SHA from the git log from the first of the included commits", commitFullMessage.contains("commit a094a8a6e8157b386b651d61997de25cd95af5eb"));
assertFalse("The integration commit message, doesn't contain lines from the original commits as expected.", commitFullMessage.contains("This is a commit message with double quotes (commit made on Windows), and =, eg. \"test quotes\"."));
//assertTrue("The integration commit message, didn't contain expected date string from the git log from the first of the included commits", commitFullMessage.contains("Wed Jun 3 09:14:28 2015 +0200"));
assertTrue("The integration commit message, didn't contain expected author string from the git log from the first of the included commits", commitFullMessage.contains("Author: Praqma Support <[email protected]>"));
assertFalse("The last commit on integration branch contain 'accumulated' but is not an accumulated commit", commitFullMessage.contains("ccumulated"));
System.out.println(String.format("***** phew... last verification (asserts) passed :-)"));
}