Skip to content

Commit 029bd43

Browse files
authored
Merge pull request #44 from 0xShubhamSolanki/add-publishTap-symbol
Add @symbol("publishTap") to TapPublisher Descriptor and pipeline test
2 parents e63e7e3 + ac3a4d9 commit 029bd43

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ test-output/
77
**/*~
88
.idea
99
*.iml
10+
.vscode/
11+

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Version 2.4.5 (2025/??/??)
44

5-
-
5+
- [GH-44](https://github.com/jenkinsci/tap-plugin/pull/44): Add @Symbol("publishTap") to TapPublisher Descriptor and pipeline test (thanks @0xShubhamSolanki)
66

77
## Version 2.4.4 (2025/03/13)
88

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ SOFTWARE.
130130
<artifactId>workflow-cps</artifactId>
131131
<scope>test</scope>
132132
</dependency>
133+
<dependency>
134+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
135+
<artifactId>workflow-step-api</artifactId>
136+
<scope>test</scope>
137+
</dependency>
138+
<dependency>
139+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
140+
<artifactId>workflow-basic-steps</artifactId>
141+
<scope>test</scope>
142+
</dependency>
133143
</dependencies>
134144

135145
<build>

src/main/java/org/tap4j/plugin/TapPublisher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.tap4j.model.TestSet;
4141
import org.tap4j.plugin.model.TestSetMap;
4242
import org.tap4j.plugin.util.Constants;
43+
import org.jenkinsci.Symbol;
4344

4445
import hudson.EnvVars;
4546
import hudson.Extension;
@@ -582,6 +583,7 @@ public MatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, B
582583
}
583584

584585
@Extension
586+
@Symbol("publishTap")
585587
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
586588
public DescriptorImpl() {
587589
super(TapPublisher.class);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright (c) 2010-2026 Bruno P. Kinoshita
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
*/
20+
package org.tap4j.plugin;
21+
22+
import hudson.model.Result;
23+
import org.junit.Rule;
24+
import org.junit.Test;
25+
import org.jvnet.hudson.test.JenkinsRule;
26+
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
27+
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
28+
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
29+
30+
public class TapPublisherPipelineTest {
31+
32+
@Rule
33+
public JenkinsRule j = new JenkinsRule();
34+
35+
@Test
36+
public void publishTapSymbolWorksWithValidTapFile() throws Exception {
37+
38+
WorkflowJob job = j.createProject(WorkflowJob.class);
39+
40+
job.setDefinition(new CpsFlowDefinition(
41+
"node {\n" +
42+
" writeFile file: 'test.log', text: '1..1\\nok 1 - Sample test\\n'\n" +
43+
" publishTap(testResults: 'test.log')\n" +
44+
"}",
45+
true
46+
));
47+
48+
WorkflowRun run = j.buildAndAssertSuccess(job);
49+
50+
j.assertBuildStatus(Result.SUCCESS, run);
51+
j.assertLogContains("TAP Reports Processing: START", run);
52+
j.assertLogContains("TAP Reports Processing: FINISH", run);
53+
}
54+
}
55+

0 commit comments

Comments
 (0)