Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-46176] Excluding children with MatrixProject parents (#34)
  • Loading branch information
v1v committed Aug 15, 2017
1 parent 2b5910a commit 6a100a8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
@@ -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;
Expand All @@ -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());
}


Expand Down
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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>";
}
Expand Down

0 comments on commit 6a100a8

Please sign in to comment.