* A previous version of GitSCM would only build against branches, not tags. This test checks that that
* regression has been fixed.
*/
public void testGitSCMCanBuildAgainstTags() throws Exception {
final String mytag = "mytag";
FreeStyleProject project = setupSimpleProject(mytag);
build(project, Result.FAILURE); // fail, because there's nothing to be checked out here
final String commitFile1 = "commitFile1";
commit(commitFile1, johnDoe, "Commit number 1");
//now create and checkout a new branch:
final String tmpBranch = "tmp";
git.branch(tmpBranch);
git.checkout(tmpBranch);
// commit to it
final String commitFile2 = "commitFile2";
commit(commitFile2, johnDoe, "Commit number 2");
assertFalse("scm polling should not detect any more changes since mytag is untouched right now",
project.pollSCMChanges(listener));
build(project, Result.FAILURE); // fail, because there's nothing to be checked out here
// tag it, then delete the tmp branch
git.tag(mytag, "mytag initial");
git.checkout("master");
git.launchCommand("branch", "-D", tmpBranch);
// at this point we're back on master, there are no other branches, tag "mytag" exists but is
// not part of "master"
assertTrue("scm polling should detect commit2 change in 'mytag'", project.pollSCMChanges(listener));
build(project, Result.SUCCESS, commitFile2);
assertFalse("scm polling should not detect any more changes after last build",
project.pollSCMChanges(listener));
// now, create tmp branch again against mytag:
git.checkout(mytag);
git.branch(tmpBranch);
// another commit:
final String commitFile3 = "commitFile3";
commit(commitFile3, johnDoe, "Commit number 3");
assertFalse("scm polling should not detect any more changes since mytag is untouched right now",
project.pollSCMChanges(listener));
// now we're going to force mytag to point to the new commit, if everything goes well, gitSCM should pick the change up:
git.tag(mytag, "mytag moved");
git.checkout("master");
git.launchCommand("branch", "-D", tmpBranch);
// at this point we're back on master, there are no other branches, "mytag" has been updated to a new commit:
assertTrue("scm polling should detect commit3 change in 'mytag'", project.pollSCMChanges(listener));
build(project, Result.SUCCESS, commitFile3);
assertFalse("scm polling should not detect any more changes after last build",
project.pollSCMChanges(listener));
}