use of hudson.FilePath in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method testTestsInStage.
@Test
public void testTestsInStage() throws Exception {
String pipeline = "" + "node {\n" + " stage ('dev') {\n" + " junit('*.xml')\n" + " }\n" + " stage ('prod') {\n" + " junit('*.xml')\n" + " }\n" + " stage ('testing') {\n" + " parallel(first: {\n" + " junit('*.xml')\n" + " },\n" + " second: {\n" + " junit('*.xml')\n" + " })\n" + " }\n" + "}\n";
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition(pipeline, true));
FilePath ws = j.jenkins.getWorkspaceFor(job1);
FilePath testFile = ws.child("test-result.xml");
testFile.copyFrom(PipelineNodeTest.class.getResource("testResult.xml"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b1);
NodeGraphBuilder builder = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(b1);
List<FlowNode> stages = getStages(builder);
Assert.assertEquals(3, stages.size());
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class);
Assert.assertEquals(5, resp.size());
resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/tests/", List.class);
Assert.assertEquals(4, resp.size());
Assert.assertEquals("dev / testDummyMethod – DummyTest", resp.get(0).get("name"));
Assert.assertEquals("prod / testDummyMethod – DummyTest", resp.get(1).get("name"));
Assert.assertEquals("testing / first / testDummyMethod – DummyTest", resp.get(2).get("name"));
Assert.assertEquals("testing / second / testDummyMethod – DummyTest", resp.get(3).get("name"));
}
use of hudson.FilePath in project violations-plugin by jenkinsci.
the class ViolationsPublisher method perform.
/**
* Called by hudson at the end of a build.
*
* @param build
* the build
* @param launcher
* the launcher
* @param listener
* for reporting errors
* @return true always.
* @throws InterruptedException
* if user cancels the operation
* @throws IOException
* if problem parsing the xml files
*/
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath htmlPath = new FilePath(new File(build.getProject().getRootDir(), VIOLATIONS));
FilePath targetPath = new FilePath(new File(build.getRootDir(), VIOLATIONS));
FilePath workspace = build.getWorkspace();
build.getActions().add(createBuildAction(workspace, targetPath, htmlPath, config, build, listener));
return true;
}
use of hudson.FilePath in project violations-plugin by jenkinsci.
the class ExecuteFilePath method execute.
/**
* Parse the file.
* @throws IOException if there is a problem.
* @throws InterruptedException if interrupted.
*/
public void execute() throws IOException, InterruptedException {
boolean seenException = false;
FilePath f = targetDir.child(filename);
PrintWriter w = new PrintWriter(new BufferedWriter(new OutputStreamWriter(f.write(), // ? for html //
"UTF-8")));
try {
ex.execute(w);
} catch (IOException ex) {
seenException = true;
throw ex;
} finally {
CloseUtil.close(w, seenException);
}
}
use of hudson.FilePath in project violations-plugin by jenkinsci.
the class StyleCopParser method parseViolations.
/**
* Parse the Violation tag and add it to the build model
* @param elements list of Violation tags
*/
private void parseViolations(List<Element> elements) throws IOException {
for (Element element : elements) {
Violation violation = new Violation();
violation.setLine(getString(element, "LineNumber"));
violation.setMessage(element.getTextContent() + " (" + getString(element, "RuleId") + ")");
violation.setSeverity(Severity.MEDIUM);
violation.setSeverityLevel(Severity.MEDIUM_VALUE);
violation.setType(TYPE_NAME);
String temp = getString(element, "RuleNamespace");
int i = temp.lastIndexOf('.');
if (i != -1) {
violation.setSource(temp.substring(i));
} else {
violation.setSource(getString(element, "RuleId"));
}
// Add the violation to the model
String displayName = new FilePath(reportParentFile).child(getString(element, "Source")).getRemote();
displayName = ParseUtil.resolveAbsoluteName(reportParentFile, displayName);
/* TODO: apply heuristics to fine the source.
StyleCop just puts whatever path representation it gets from MSBuild into @Source,
which can be relative (to the current directory MSBuild run in, which we won't know.)
In such a case, there's really no reliable way for us to deterministically figure out
where the source code is in the source tree.
The resolution against 'reportParentFile' is quite arbitrary in that sense and only
works if the report is created into the same directory as the MSBuild current directory,
but it is a backward compatible behaviour.
*/
FullFileModel fileModel = model.getFileModel(displayName);
fileModel.addViolation(violation);
}
}
Aggregations