@JenkinsRule plugin list customisation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

@JenkinsRule plugin list customisation

Radosław Antoniuk
In the context of
how can I customise the list of plugins that the test runs with to detect a missing dependency in tests?

There is https://wiki.jenkins.io/display/JENKINS/Unit+Test#UnitTest-@WithPlugin(NameOfPlugin)
but there is no @WithoutPlugin and it seems that JenkinsRule somehow installs credentials plugin even though it is not mentioned in pom.xml.
I suppose it is using "Suggested plugins list" but I couldn't find it anywhere in JenkinsRule class..

Btw - how can I find easily the corresponding jenkins.io/doc/ of a specific page on the old docs - e.g. https://wiki.jenkins.io/display/JENKINS/Unit+Test#UnitTest-@WithPlugin(NameOfPlugin). 
Can the links to the new site be automatically or manually added ?

Cheers,
Radek

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/b57a1c40-b70a-45f6-88e6-53abbf77f012n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: @JenkinsRule plugin list customisation

Radosław Antoniuk
Whoops, the context link got deleted. 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPe2pWjBdaORacXVL_U%3DHxU0TdLX%2Bj0t8nqFhoi-_-QG26pSuQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: @JenkinsRule plugin list customisation

Jesse Glick-4
In reply to this post by Radosław Antoniuk
On Fri, Oct 23, 2020 at 7:30 AM Radek Antoniuk <[hidden email]> wrote:
> how can I customise the list of plugins that the test runs with

Normally you do not do anything besides have plugins of interest in
your Maven test classpath. `@WithPlugin` is tricky and rarely needed.

> to detect a missing dependency in tests?

What specifically are you trying to accomplish? Reproducing
JENKINS-64002 in a test? Not going to work (see JENKINS-41827). Your
mistake can be seen from `mvn dependency:tree`:

[INFO] +- org.jenkins-ci.plugins:p4:jar:1.3.8:compile (optional)
[INFO] |  +- org.jenkins-ci.plugins:credentials:jar:2.3.13:compile (optional)

You explicitly use the `credentials` plugin’s APIs, so you should have
a direct dependency on it. (check `mvn dependency:analyze`)

In general, use `optional` dependencies only with extreme care; see
JENKINS-19508 for discussion.

BTW your plugin does not build in `master`, perhaps because #277
introduced a mistake that #290 caught, or similar.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3RJHMRMN37iVJ_kW6f%2BmetF56H1_0GJdzx4FRhmKy4kw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: @JenkinsRule plugin list customisation

Radosław Antoniuk
On Fri, Oct 23, 2020 at 2:27 PM Jesse Glick <[hidden email]> wrote:
On Fri, Oct 23, 2020 at 7:30 AM Radek Antoniuk <[hidden email]> wrote:
> how can I customise the list of plugins that the test runs with

Normally you do not do anything besides have plugins of interest in
your Maven test classpath. `@WithPlugin` is tricky and rarely needed.

> to detect a missing dependency in tests?

What specifically are you trying to accomplish? Reproducing
JENKINS-64002 in a test? Not going to work (see JENKINS-41827). Your
mistake can be seen from `mvn dependency:tree`:

[INFO] +- org.jenkins-ci.plugins:p4:jar:1.3.8:compile (optional)
[INFO] |  +- org.jenkins-ci.plugins:credentials:jar:2.3.13:compile (optional)


You explicitly use the `credentials` plugin’s APIs, so you should have
a direct dependency on it. (check `mvn dependency:analyze`)

It took me a while to understand what you wrote and happenned here, but I think I got it right now.

p4 is optional and it should stay there IMHO. perforce functionality is absolutely custom and therefore optional for jira plugin for users using git (majority).
The JENKINS-64002 bug is however about basic Credential user/password saving to JIRA instance itself that bails out at the main manage configuration
screen.

So if I read you correct, you are saying that all the  org.jenkins-ci.plugin:*:compile dependencies that are in the "Undeclared used dependencies" output from dependency:analyze - should be added to direct dependencies?

And indeed, that's exactly what I would like to "detect with @JenkinsRule or during compilation phase" - but the root cause here was that the p4 maven included "credentials api" for compilation through optional p4 dependency but not introduced a direct plugin dependency in Jenkins plugin system.
 
So I think that the better solution is to actually exclude org.jenkins-ci.plugin:* from the optional dependencies instead - see https://github.com/jenkinsci/jira-plugin/pull/292/files
This way the plugin fails on compilation with no direct dependency declared and still optional dependency is ok.

Thanks a lot for pointing in the right direction!


In general, use `optional` dependencies only with extreme care; see
JENKINS-19508 for discussion.

BTW your plugin does not build in `master`, perhaps because #277
introduced a mistake that #290 caught, or similar.
 
Not sure what you mean, the plugin pipeline is green on master branch - https://github.com/jenkinsci/jira-plugin
 

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPe2pWirbT4eYsMuSv2Bw_AQ-mrkGCBYv%2B%3DJfGN7ubK7UZ6C9w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: @JenkinsRule plugin list customisation

Jesse Glick-4
On Fri, Oct 23, 2020 at 1:00 PM Radosław Antoniuk
<[hidden email]> wrote:
> you are saying that all the  org.jenkins-ci.plugin:*:compile dependencies that are in the "Undeclared used dependencies" output from dependency:analyze - should be added to direct dependencies?

Yes, something like that. We do not currently try to enforce this
mechanically since the exceptions are tricky to characterize.

> exclude org.jenkins-ci.plugin:* from the optional dependencies instead - see https://github.com/jenkinsci/jira-plugin/pull/292/files

Fine if all of those excluded dependencies are added as direct
dependencies anyway. If they are not, then you might run into
`ClassNotFoundException`’s in tests, depending on what you are
testing.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr27WKJ2tAFpnobg0ksjMc5DiomMn%3DsHTXUgCnhkCUD3Vw%40mail.gmail.com.