New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fixed JENKINS-23532] Search Folders when trying to find upstream project #108
Changes from all commits
e37f6fc
406b66c
7eab095
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,27 +31,28 @@ | |
import au.com.centrumsystems.hudson.plugin.buildpipeline.BuildPipelineView; | ||
import au.com.centrumsystems.hudson.plugin.buildpipeline.DownstreamProjectGridBuilder; | ||
import au.com.centrumsystems.hudson.plugin.buildpipeline.extension.StandardBuildCard; | ||
import hudson.model.AbstractProject; | ||
import hudson.model.Cause; | ||
import hudson.model.Descriptor; | ||
import hudson.model.FreeStyleBuild; | ||
import hudson.model.FreeStyleProject; | ||
import hudson.model.Hudson; | ||
import hudson.plugins.parameterizedtrigger.AbstractBuildParameters; | ||
import hudson.EnvVars; | ||
import hudson.model.*; | ||
import hudson.plugins.parameterizedtrigger.*; | ||
|
||
import hudson.tasks.Publisher; | ||
import hudson.util.DescribableList; | ||
import hudson.util.FormValidation; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.NoSuchElementException; | ||
|
||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Bug; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.*; | ||
|
||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* BuildPipelineTrigger test class | ||
|
@@ -246,6 +247,87 @@ public void testManualTriggerCause() throws Exception | |
assertNotNull(upstreamCause); | ||
} | ||
|
||
@Test | ||
@Issue("JENKINS-23532") | ||
public void testTriggerProjectInFolderUsingParameteriezedTrigger() | ||
throws Exception | ||
{ | ||
//root folder | ||
MockFolder folder1 = jenkins.createFolder("Folder1"); | ||
MockFolder folder2 = jenkins.createFolder("Folder2"); | ||
|
||
// /Folder1 | ||
final String projUp = "upstream"; | ||
folder1.createProject(FreeStyleProject.class, projUp); | ||
//FreeStyleProject upstreamProject = (FreeStyleProject) folder1.getItem(projUp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove? |
||
FreeStyleProject upstreamProject = jenkins.createFreeStyleProject(projUp); | ||
|
||
// /Folder2 | ||
final String projDown = "downstream"; | ||
folder2.createProject(FreeStyleProject.class, projDown); | ||
FreeStyleProject downstreamProject = (FreeStyleProject) folder2.getItem(projDown); | ||
|
||
BuildTriggerConfig notFakeConfig = new BuildTriggerConfig("Folder2/downstream", ResultCondition.ALWAYS, false, | ||
Collections.singletonList((AbstractBuildParameters) new CurrentBuildParameters())); | ||
upstreamProject.getPublishersList().add(new hudson.plugins.parameterizedtrigger.BuildTrigger(notFakeConfig)); | ||
jenkins.getInstance().rebuildDependencyGraph(); | ||
|
||
BuildPipelineView view = new BuildPipelineView("Pipeline", "Title", new DownstreamProjectGridBuilder("upstream"), "1", false, ""); | ||
view.setBuildCard(new StandardBuildCard()); | ||
jenkins.buildAndAssertSuccess(upstreamProject); | ||
|
||
view.triggerManualBuild(1, downstreamProject.getFullName(), upstreamProject.getFullName()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has upstream automatically started to build the downstream? And if so, does this mean that we are triggering a re-run and not a first-run, which had the problem we must reproduce? You can verify this by asserting null on the downstream project's latest build. If it has in fact started, a work-around would be to define the downstream project and configuration in the upstream project after the upstream has been run once. |
||
|
||
jenkins.waitUntilNoActivity(); | ||
|
||
assertNotNull(downstreamProject.getLastBuild()); | ||
FreeStyleBuild build = downstreamProject.getLastBuild(); | ||
Cause.UserIdCause cause = build.getCause(Cause.UserIdCause.class); | ||
assertNotNull(cause); | ||
//Check that cause is of core class Cause.UserIdCause and not MyUserIdCause | ||
assertEquals(Cause.UserIdCause.class.getName(), cause.getClass().getName()); | ||
Cause.UpstreamCause upstreamCause = build.getCause(Cause.UpstreamCause.class); | ||
assertNotNull(upstreamCause); | ||
} | ||
|
||
@Test | ||
public void testTriggerProjectInFolderUsingHudsonTrigger() | ||
throws Exception | ||
{ | ||
//root folder | ||
MockFolder folder1 = jenkins.createFolder("Folder1"); | ||
MockFolder folder2 = jenkins.createFolder("Folder2"); | ||
|
||
// /folder1 | ||
final String projUp = "upstream"; | ||
folder1.createProject(FreeStyleProject.class, projUp); | ||
FreeStyleProject upstreamProject = (FreeStyleProject) folder1.getItem(projUp); | ||
|
||
// /folder2 | ||
final String projDown = "downstream"; | ||
folder2.createProject(FreeStyleProject.class, projDown); | ||
FreeStyleProject downstreamProject = (FreeStyleProject) folder2.getItem(projDown); | ||
|
||
upstreamProject.getPublishersList().add(new hudson.tasks.BuildTrigger(downstreamProject.getFullName(), false)); | ||
jenkins.getInstance().rebuildDependencyGraph(); | ||
|
||
BuildPipelineView view = new BuildPipelineView("Pipeline", "Title", new DownstreamProjectGridBuilder("upstream"), "1", false, ""); | ||
view.setBuildCard(new StandardBuildCard()); | ||
jenkins.buildAndAssertSuccess(upstreamProject); | ||
|
||
view.triggerManualBuild(1, downstreamProject.getFullName(), upstreamProject.getFullName()); | ||
|
||
jenkins.waitUntilNoActivity(); | ||
|
||
assertNotNull(downstreamProject.getLastBuild()); | ||
FreeStyleBuild build = downstreamProject.getLastBuild(); | ||
Cause.UserIdCause cause = build.getCause(Cause.UserIdCause.class); | ||
assertNotNull(cause); | ||
assertEquals(Cause.UserIdCause.class.getName(), cause.getClass().getName()); | ||
Cause.UpstreamCause upstreamCause = build.getCause(Cause.UpstreamCause.class); | ||
assertNotNull(upstreamCause); | ||
} | ||
|
||
@Test | ||
@Issue("JENKINS-24883") | ||
public void testReRunBuildPipelineTrigger() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1