-
-
Notifications
You must be signed in to change notification settings - Fork 77
[JENKINS-48924, JENKINS-48995] - Fix plugin compatibility with Jenkins 2.102+ #29
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
Changes from all commits
d8e49b6
9bf81a9
8b93d29
c3b85cd
2429714
a92f258
b56640e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,32 +25,52 @@ | |
|
|
||
| import hudson.model.Action; | ||
| import hudson.model.AbstractBuild; | ||
| import hudson.model.Run; | ||
| import hudson.plugins.testlink.util.TestLinkHelper; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| import jenkins.model.RunAction2; | ||
| import org.kohsuke.stapler.StaplerProxy; | ||
|
|
||
| /** | ||
| * @author Bruno P. Kinoshita - http://www.kinoshita.eti.br | ||
| * @since 1.0 | ||
| */ | ||
| public class TestLinkBuildAction implements Action, Serializable, StaplerProxy { | ||
| public class TestLinkBuildAction implements RunAction2, Serializable, StaplerProxy { | ||
|
|
||
| private static final long serialVersionUID = -914904584770393909L; | ||
|
|
||
| public static final String DISPLAY_NAME = "TestLink"; | ||
| public static final String ICON_FILE_NAME = "/plugin/testlink/icons/testlink-24.png"; | ||
| public static final String URL_NAME = "testLinkResult"; | ||
|
|
||
| private AbstractBuild<?, ?> build; | ||
| private transient Run<?, ?> build; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good, making this |
||
| private TestLinkResult result; | ||
|
|
||
| public TestLinkBuildAction(TestLinkResult result) { | ||
| this.result = result; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated Use {@link #TestLinkBuildAction(TestLinkResult)} without build definition. | ||
| */ | ||
| @Deprecated | ||
| public TestLinkBuildAction(AbstractBuild<?, ?> build, TestLinkResult result) { | ||
| this.build = build; | ||
| this.result = result; | ||
| } | ||
|
|
||
| @Override | ||
| public void onLoad(Run<?, ?> r) { | ||
| this.build = r; | ||
| } | ||
|
|
||
| @Override | ||
| public void onAttached(Run<?, ?> r) { | ||
| this.build = r; | ||
| } | ||
|
|
||
| public String getDisplayName() { | ||
| return DISPLAY_NAME; | ||
| } | ||
|
|
@@ -67,10 +87,25 @@ public Object getTarget() { | |
| return this.result; | ||
| } | ||
|
|
||
| public AbstractBuild<?, ?> getBuild() { | ||
| /** | ||
| * Gets Run to which the action is attached. | ||
| * @return Run instance | ||
| * @since TODO | ||
| */ | ||
| public Run<?, ?> getRun() { | ||
| return build; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated Use {@link #getRun()} | ||
| */ | ||
| public AbstractBuild<?, ?> getBuild() { | ||
| if (build instanceof AbstractBuild<?, ?>) { | ||
| return (AbstractBuild<?, ?>)build; | ||
| } | ||
| throw new IllegalStateException("Calling old API against a non-AbstractBuild run type. Run: " + build); | ||
| } | ||
|
|
||
| /** | ||
| * @return TestLink job execution result | ||
| */ | ||
|
|
@@ -107,7 +142,7 @@ public TestLinkResult getPreviousResult() { | |
| */ | ||
| public TestLinkBuildAction getPreviousAction() { | ||
| if (this.build != null) { | ||
| AbstractBuild<?, ?> previousBuild = this.build.getPreviousBuild(); | ||
| Run<?, ?> previousBuild = this.build.getPreviousBuild(); | ||
| if (previousBuild != null) { | ||
| return previousBuild.getAction(TestLinkBuildAction.class); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |
| */ | ||
| package hudson.plugins.testlink.result; | ||
|
|
||
| import hudson.FilePath.FileCallable; | ||
| import hudson.model.BuildListener; | ||
| import hudson.model.Result; | ||
| import hudson.model.AbstractBuild; | ||
|
|
@@ -33,9 +32,7 @@ | |
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| import org.jenkinsci.remoting.Role; | ||
| import org.jenkinsci.remoting.RoleChecker; | ||
| import org.jenkinsci.remoting.RoleSensitive; | ||
| import jenkins.MasterToSlaveFileCallable; | ||
|
|
||
| import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus; | ||
| import br.eti.kinoshita.testlinkjavaapi.model.Attachment; | ||
|
|
@@ -44,6 +41,8 @@ | |
| import com.tupilabs.testng.parser.Suite; | ||
| import com.tupilabs.testng.parser.TestNGParser; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * @author Bruno P. Kinoshita - http://www.kinoshita.eti.br | ||
| * @since 3.1 | ||
|
|
@@ -58,7 +57,7 @@ public abstract class AbstractTestNGResultSeeker extends ResultSeeker { | |
|
|
||
| public static final String TEXT_XML_CONTENT_TYPE = "text/xml"; | ||
|
|
||
| protected final TestNGParser parser = new TestNGParser(); | ||
| protected transient TestNGParser _parser = null; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class could be actually made static, but it needs update of the bundled lib
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe should be
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not matter much. In the worst case there will be two instances of a same class which actually has no dynamic context at all. The class methods should be reworked to static, I just decided not to do breaking changes in this PR |
||
|
|
||
| private boolean attachTestNGXML = false; | ||
|
|
||
|
|
@@ -70,6 +69,14 @@ public AbstractTestNGResultSeeker(String includePattern, String keyCustomField, | |
| this.markSkippedTestAsBlocked = markSkippedTestAsBlocked; | ||
| } | ||
|
|
||
| @Nonnull | ||
| protected TestNGParser getParser() { | ||
| if (_parser == null) { | ||
| _parser = new TestNGParser(); | ||
| } | ||
| return _parser; | ||
| } | ||
|
|
||
| public void setAttachTestNGXML(boolean attachTestNGXML) { | ||
| this.attachTestNGXML = attachTestNGXML; | ||
| } | ||
|
|
@@ -92,7 +99,7 @@ protected void handleResult(TestCaseWrapper automatedTestCase, AbstractBuild<?, | |
| final int executionId = testlink.updateTestCase(automatedTestCase); | ||
|
|
||
| if(executionId > 0 && this.isAttachTestNGXML()) { | ||
| Attachment attachment = build.getWorkspace().act( new FileCallable<Attachment>() { | ||
| Attachment attachment = build.getWorkspace().act( new MasterToSlaveFileCallable<Attachment>() { | ||
|
|
||
| private static final long serialVersionUID = -5411683541842375558L; | ||
|
|
||
|
|
@@ -112,11 +119,6 @@ public Attachment invoke(File f, | |
|
|
||
| return attachment; | ||
| } | ||
|
|
||
| @Override | ||
| public void checkRoles(RoleChecker roleChecker) throws SecurityException { | ||
| roleChecker.check((RoleSensitive) this, Role.UNKNOWN); | ||
| } | ||
| }); | ||
| testlink.uploadAttachment(executionId, attachment); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly, #25 does not do that