Skip to content
Permalink
Browse files

[JENKINS-46176] Excluding children with MatrixProject parents

Change-Id: I7fda70ed7d44e4bf5dc52bf72f5584271dd4f1c7
  • Loading branch information...
v1v committed Aug 14, 2017
1 parent 2b5910a commit ecea07d38d99bfcc772d349038bbab74132d9e7e
@@ -1,13 +1,13 @@
package org.jenkins.ci.plugins.jenkinslint;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Node;
import hudson.model.RootAction;
import jenkins.model.Jenkins;
import org.jenkins.ci.plugins.jenkinslint.model.*;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

import java.io.IOException;
import java.util.Hashtable;
import java.util.logging.Level;
@@ -30,15 +30,20 @@ public void getData() throws IOException {
this.reloadSlaveCheckList();

for (hudson.model.Job item : Jenkins.getInstance().getAllItems(hudson.model.Job.class)) {
LOG.log(Level.FINER, "queryChecks " + item.getName());
Job newJob = new Job(item.getName(), item.getUrl());
for (InterfaceCheck checker : this.getCheckList()) {
LOG.log(Level.FINER, checker.getName() + " " + item.getName() + " " + checker.executeCheck(item));
// Lint is disabled when is ignored or globally disabled
newJob.addLint(new Lint(checker.getName(), checker.executeCheck(item), checker.isIgnored(item.getDescription()), checker.isEnabled()));
// Fixing MatrixJobs @JENKINS-46176
if (!item.getParent().getClass().getSimpleName().equals("MatrixProject")) {
LOG.log(Level.FINER, "queryChecks " + item.getName());
Job newJob = new Job(item.getName(), item.getUrl());
for (InterfaceCheck checker : this.getCheckList()) {
LOG.log(Level.FINER, checker.getName() + " " + item.getName() + " " + checker.executeCheck(item));
// Lint is disabled when is ignored or globally disabled
newJob.addLint(new Lint(checker.getName(), checker.executeCheck(item), checker.isIgnored(item.getDescription()), checker.isEnabled()));
}
jobSet.put(item.getName(), newJob);
LOG.log(Level.FINER, newJob.toString());
} else {
LOG.log(Level.FINER, "Excluded MatrixConfiguration " + item.getName());
}
jobSet.put(item.getName(),newJob);
LOG.log(Level.FINER, newJob.toString());
}


@@ -5,10 +5,16 @@
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import hudson.matrix.Axis;
import hudson.matrix.AxisList;
import hudson.matrix.MatrixProject;
import hudson.matrix.TextAxis;
import hudson.model.FreeStyleProject;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.Issue;

import java.util.ArrayList;
import java.util.List;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.*;
@@ -85,6 +91,26 @@ public void testUITable() throws Exception {
assertTrue(content.contains(htmlLint("BFAChecker", "JL-21")));
}

@Issue("JENKINS-46176")
@Test
public void testMatrixJobWithConfigurations() throws Exception {
String jobName = "JOB";
MatrixProject project = j.createMatrixProject(jobName);
List<Axis> axes = new ArrayList<Axis>();
for (int i = 1; i <= 2; i++) {
List<String> vals = new ArrayList<String>();
for (int j = 1; j <= i; j++) {
vals.add(Integer.toString(j));
}
axes.add(new TextAxis("axis" + i, vals));
}
project.setAxes(new AxisList(axes));
HtmlPage page = j.createWebClient().goTo(URL);
String content = page.getWebResponse().getContentAsString();
assertFalse(content.contains("axis"));
}


private String htmlLint (String name, String id) {
return "<th tooltip=\"" + name + "\" class=\"pane-header\">" + id + "</th>";
}

0 comments on commit ecea07d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.