|
@@ -25,6 +25,7 @@ |
|
|
|
|
|
package integration; |
|
|
|
|
|
import hudson.model.FreeStyleProject; |
|
|
import hudson.model.TopLevelItem; |
|
|
import integration.harness.BasicBranchProjectFactory; |
|
|
import integration.harness.BasicDummyStepBranchProperty; |
|
@@ -35,6 +36,7 @@ |
|
|
import jenkins.scm.impl.mock.MockSCMController; |
|
|
import jenkins.scm.impl.mock.MockSCMDiscoverBranches; |
|
|
import jenkins.scm.impl.mock.MockSCMDiscoverChangeRequests; |
|
|
import jenkins.scm.impl.mock.MockSCMDiscoverTags; |
|
|
import jenkins.scm.impl.mock.MockSCMSource; |
|
|
import org.junit.Before; |
|
|
import org.junit.ClassRule; |
|
@@ -44,6 +46,7 @@ |
|
|
import static org.hamcrest.Matchers.allOf; |
|
|
import static org.hamcrest.Matchers.anyOf; |
|
|
import static org.hamcrest.Matchers.containsString; |
|
|
import static org.hamcrest.Matchers.nullValue; |
|
|
import static org.junit.Assert.assertThat; |
|
|
|
|
|
public class EnvironmentTest { |
|
@@ -131,20 +134,24 @@ public void given_multibranch_when_buildingAChangeRequest_then_environmentContai |
|
|
} |
|
|
} |
|
|
|
|
|
@Test |
|
|
public void given_multibranch_when_buildingATag_then_environmentContainsTagName() throws Exception { |
|
|
try (MockSCMController c = MockSCMController.create()) { |
|
|
c.createRepository("foo"); |
|
|
c.createTag("foo", "master", "release"); |
|
|
BasicMultiBranchProject prj = r.jenkins.createProject(BasicMultiBranchProject.class, "foo"); |
|
|
prj.setCriteria(null); |
|
|
prj.setProjectFactory(new BasicBranchProjectFactory()); |
|
|
BranchSource source = new BranchSource(new MockSCMSource(null, c, "foo", true, true, false)); |
|
|
BranchSource source = new BranchSource(new MockSCMSource(c, "foo", new MockSCMDiscoverBranches(), new MockSCMDiscoverTags())); |
|
|
source.setStrategy( |
|
|
new DefaultBranchPropertyStrategy(new BranchProperty[]{new BasicDummyStepBranchProperty()})); |
|
|
prj.getSourcesList().add(source); |
|
|
prj.scheduleBuild2(0).getFuture().get(); |
|
|
r.waitUntilNoActivity(); |
|
|
assertThat(r.getLog(prj.getItem("release").getBuildByNumber(1)), containsString("TAG_NAME=release")); |
|
|
FreeStyleProject job = prj.getItem("release"); |
|
|
assertThat(job.getLastBuild(), nullValue()); |
|
|
r.buildAndAssertSuccess(job); |
|
|
assertThat(r.getLog(job.getBuildByNumber(1)), containsString("TAG_NAME=release")); |
|
|
} |
|
|
} |
|
|
|
|
|