-
Notifications
You must be signed in to change notification settings - Fork 158
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
Make plugin compatible with Workflow #13
Make plugin compatible with Workflow #13
Conversation
@janario please review and provide feedback. I would like these changes to be included in the next official release. This pull request prepares the plugin for workflow integration, which will require a new custom build step to be developed in a subsequent pull request. |
Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests. |
@@ -4,7 +4,7 @@ | |||
<groupId>org.jenkins-ci.plugins</groupId> | |||
<artifactId>plugin</artifactId> | |||
|
|||
<version>1.509.4</version> | |||
<version>1.609.1</version> |
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.
Needs a review from plugin maintainers. I'm not sure which baselines do they target
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.
1.580.1 would be the usual minimum for Pipeline compatibility (up to 1.4.2). But if the maintainer agrees, this is fine too.
There're much unrelated formatting and functional changes. Would be great if they go to separate pull-requests or at least commits |
Thank you for this code review, it helps me improve the code.
I am not sure how to separate into multiple commits or multiple pull-requests but I will think about it. I made some changes not because they were absolutely necessary, but because it made it easier for me to implement the Workflow compatibility. As far I can can tell, I have maintained compatibility at the freestyle build level (that's why I wrote so many tests). As an example, the lack of TEXT_PLAIN mime type was not a bug nor a feature request, but it made it a bit easier to write the tests. Another example is that the author was not using the maven-hpi-plugin, but it was recommended I use it, so I put it in. The slf4j upgrade was not necessary, but along the way I've put it in probably because of something else I tried that needed it. The NPE serialization issue came up, but it has nothing to do with Workflow per say, however, it got in the way at some point, so I fixed it. The code snippet generator was also very useful. At first it would come up with almost all the arguments as being necessary. So I worked on improving how default arguments and default values came about. Now the snippet generator only show the mandatory arguments, and has default values (rather than null) for the other arguments. From the outside, I guess these "formatting" changes look unnecessary? I think some of the code formatting comes from breaking the constructor as per the COMPATIBILITY.md recommendations, and placing the setters/getters in the same order as they are in the jelly code. So no matter which file you read, the user parameters are ordered the same way. |
@oleg-nenashev I have a split this PR into more commits, how would you like me to present them? Should I force update this PR, or create a new PR? Thanks. |
Follow the COMPATIBILITY.md guidelines Add public boolean perform(AbstractBuild<?, ?> build, ...) method for non-workflow java compatibility Bug fix: expect entity to be null in response to HEAD method request Fix serialization by removing the logger which could be null and cause NPE Use apache LocalServerTestBase to test request content Support the TEXT_PLAIN mime type to simplify testing Better error message when return code is out of acceptable bounds Build parameters are passed as code when in Workflow Skip outputFile writing when Workspace is null and inform user about it
@martinda |
169b1c5
to
9708ce1
Compare
@oleg-nenashev the code is ready for more review. I have pushed a short series of commits that attempt to separate changes in a few categories. |
|
||
// Check expectations | ||
j.assertBuildStatusSuccess(build); | ||
String s = FileUtils.readFileToString(build.getLogFile()); |
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.
Easier (to read and maintain) with j.assertLogContains("All is well", build)
Didn't try to run it, but looks good to me. A couple of tips:
|
throws InterruptedException, IOException { | ||
perform(build, build.getWorkspace(), launcher, listener); | ||
return true; | ||
} |
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.
No need to retain this overload. The super
implementation will call the new one automatically.
Mostly OK but deserves a Pipeline-specific functional test, and there are some fixes needed in the databinding (which should anyway make the UI code simpler and more regular). |
@@ -56,4 +78,16 @@ | |||
<email>janarioliver@gmail.com</email> | |||
</developer> | |||
</developers> | |||
|
|||
<build> | |||
<pluginManagement> |
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.
pluginManagment doesn't make any sense in non multi-module project. why do you need it?
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.
@KostyaSha It is to use the maven-hpi-plugin, I was told it would give me some built-in tests. What is a the correct way to use maven-hpi-plugin?
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.
if it works, then ok. I thought that you need to set plugin directly in build tag
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.
I removed the pluginManagement
element and it also works, so I am removing it. Thanks.
I think this plugin misuses |
Agreed, from what I can see |
Judging by the console log where I sent a |
Does http-request-plugin support for workflow/pipeline supports REST api invocation using certificates? |
Any chance of this being merged soon? Is the code as it stands safe to use, even if not integrated? It sounds like the only issue is with tests timing out. Correct? |
@omehegan There is an issue with the migration of the global configuration for the plugin. I have reproduced the issue in a separate repository. As soon as that is figured out, I can fix this PR. I should add that I am not actively working on this particular issue at this time, because I have run out of ideas on what to do. Any help appreciated! |
OK. Sounds like if I have never used the plugin before, I could install this branch and be fine? I was looking for this exact functionality! |
Hi guys, First of all I have to thank you all about the review and suggestions on this PR. @martinda I really liked the PR, especially about the test cases :) I have some questions and some suggestions bellow Guys, jenkins plugin parent 2.3, Will this make the plugin incompatible with old versions of jenkins? @martinda , you can add @ author tag in all classes you have created. :) TestCases Tests cases are failing because of OOME. As I've tested with Xmx320m is good enough. Can you configure it?
Global configuration As you said, there is a compatibility problem in global configuration.
Once removed the global deprecated configuration 'defaultHttpMode', 'defaultReturnCodeBuildRelevant', 'defaultLogResponseBody' Job configuration
And last, I'm having an error while executing a job on jenkins. Following the log:
Once again thank you all :) |
@janario Glad to see you! Thanks for the feedback, I can make progress again. The minimum Jenkins version is 1.609.3. I tried many times to keep it lower than that, but when it came to testing and to the Pipeline features, that's the best I was able to do. Regarding the parent pom at 2.3, I do not know, but it does not appear to be related to the Jenkins version itself. Regarding your last item with the loader constraint violation, what Jenkins version are you using? I am pushing some changes now, and I'll try to add the |
Please help me with this |
@janario I have added the code you recommended. I have written a few test to see if I could verify the If you could have a look at the tests in abea7b6 and in 1611420, and give me some advice, I would really like my tests to be meaningful. |
@martinda HttpRequestBackwardCompatibilityTest.defaultGlobalConfig It passes without the compatibility methods because the xml has the same value of a new instance of HttpRequestGlobalConfig, then without getConfigFile it just create a new instance but linked to a wrong file '< jenkins_home >/jenkins.plugins.http_request.HttpRequestGlobalConfig.xml' where it was expected to be '< jenkins_home >/jenkins.plugins.http_request.HttpRequest.xml'
HttpRequestBackwardCompatibilityTest.populatedGlobalConfig HttpRequestBackwardCompatibilityTest.oldConfigWithoutCustomHeadersShouldLoad
About the exception I'm having, I've run it with 'mvn hpi:run' which starts jenkins v1.609.3 |
@janario Thank you, I was able to enhance the tests and add a new test. I am getting the same exception with |
Closing to see if it clears the problem with mixing PR 13 and PR 14. |
It turns out With 4.5.1, the exception is:
I do not understand my mistake. What is special about |
I fixed it with 'pluginFirstClassLoader' configuration. Thanks. :) |
Support vim files in .gitignore
Deprecated global properties marked to be deprecated
Refactored code as per Workflow Compatibility guide
Fixed serialization NPE
Add TEXT_PLAIN mime type
Use maven-hpi-plugin for built-in plugin tests
Set slf4j-api to 1.7.13 (latest at this time)
Better error message when return code is out of bounds
Set the default timeout value for workflow
Added many tests