Skip to content
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

Merged
merged 3 commits into from Jun 19, 2017

Conversation

JamesForsee
Copy link

@JamesForsee JamesForsee commented Jun 12, 2017

[Fixed JENKINS-23532] Manually triggering build will now search other folders for the upstream project

@dalvizu dalvizu changed the title Search Folders when trying to find upstream project [Fixed JENKINS-23532] Search Folders when trying to find upstream project Jun 13, 2017
* @param searchTerm - name of the item that is being looked for
* @return the project that matched the search term
*/
private AbstractProject<?, ?> traverseItemGroupHelper(ItemGroup groupToTraverse, String searchTerm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a boundary case here where there can be a job with the same name (say, "Prod Commit") but in separate folders. This will always return the first folder to contain a job named "Prod Commit".

However this is also not where the issue is - we are able to correctly identify the upstream project and upstream build from the information the JS passes us

LOGGER.fine("Downstream project names: " + downstreamProjectsNames);
// defect: requires full name in the trigger. But downstream is just fine!
if (downstreamProjectsNames.contains(project.getFullName())) {

if (downstreamProjectsNames.contains(project.getName())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous case is not the issue - we correctly identify the project by full name because we require build pipeline trigger to be specified by full name (well, before the change above). The problem is on line line 299 (line 350 in your branch) -- this assumes that the BuildTrigger config is also being specified by full name. This is not a safe assumption - it is in fact always going to be specified by a relative name (i.e admin-api/Prod Build/), which we compare to our full name and the mismatch happens

@dalvizu
Copy link
Member

dalvizu commented Jun 13, 2017

I do not think we want to allow projects to be specified by just their short project name -- this introduces cases where builds with the same name cannot be reliably chosen. The plugin today assumes a full name for a manual trigger, while automatic triggers assume a relative name. The bug we are trying to fix is that automatic trigger will never be found if it ever needs to be manually triggered on the first build (say after a restart or a re-run when history was erased)

@dalvizu
Copy link
Member

dalvizu commented Jun 14, 2017

This is how BuildTrigger handles lookup - we will want to do the same -
It consults the DependencyGraph

https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/tasks/BuildTrigger.java#L254

@JamesForsee JamesForsee reopened this Jun 19, 2017
for (String currentDownstreamName : downstreamProjectsNames) {
final Job downstreamJob = (Job) Jenkins.getInstance().getItem(currentDownstreamName,
upstreamBuild.getProject().getParent(), Item.class);
if (downstreamJob != null && downstreamJob.getFullName().equals(project.getFullName())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

view.setBuildCard(new StandardBuildCard());
jenkins.buildAndAssertSuccess(upstreamProject);

view.triggerManualBuild(1, downstreamProject.getFullName(), upstreamProject.getFullName());
Copy link
Member

Choose a reason for hiding this comment

The 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.

// /Folder1
final String projUp = "upstream";
folder1.createProject(FreeStyleProject.class, projUp);
//FreeStyleProject upstreamProject = (FreeStyleProject) folder1.getItem(projUp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

@dalvizu dalvizu merged commit 6300e17 into jenkinsci:JENKINS-38670 Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants