If it's your code normally you would inject yourself via the constructor.

If it's Jenkins dependencies you would get them via
'getContex().get(Computer.class)'

Example PR where I removed Guice recently:
https://github.com/jenkinsci/sauce-ondemand-plugin/pull/83/files
Jump to src/main/java/com/saucelabs/jenkins/pipeline/SauceConnectStep.java

Thanks
Tim

On Wed, 30 Jun 2021 at 10:32, Goyot, Martin <[email protected]>
wrote:

> > Maybe a pointer to the code would be helpful...
>
> Sure. Here is some in an internal class that we use where we @Inject some
> dependencies
> https://github.com/jenkinsci/tuleap-api-plugin/blob/master/src/main/java/io/jenkins/plugins/tuleap_api/client/internals/TuleapApiClient.java.
> Here is another example with a `SecurityRealm`
> https://github.com/jenkinsci/tuleap-oauth-plugin/blob/8494eb096d2dc7d80011b577d9bd9116d9688a64/src/main/java/io/jenkins/plugins/tuleap_oauth/TuleapSecurityRealm.java#L151
> where we use the `injectMembers(this)` strategy with the setters.
>
> > Which dependencies do you mean? Normally there is no need to use
> dependency injection in Jenkins at all. Typically all required objects are
> provided as parameters to the extension point methods.
>
> I'm not necessarily talking about Jenkins dependencies that are provided
> by Jenkins itself but dependencies coming from our own code.
>
> --
>
>
>
>
> <https://www.tuleap.org/fr/ebook-agilite-a-lechelle/?utm_source=signature-mail&utm_medium=martin-goyot&utm_campaign=banner-mail-promo-ebook-1>
>
>
> Le mer. 30 juin 2021 à 10:30, Daniel Beck <[email protected]> a écrit :
>
>>
>>
>> On Wed, Jun 30, 2021 at 9:47 AM Ullrich Hafner <[email protected]>
>> wrote:
>>
>>> Which dependencies do you mean? Normally there is no need to use
>>> dependency injection in Jenkins at all. Typically all required objects are
>>> provided as parameters to the extension point methods.
>>>
>>
>> Didn't you write the JenkinsFacade to make that testable without a full
>> instance running? :-)
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7PtJiFhOTAcMwELiuz3w9iza51DLJFF%3Df4tidnuQfzpZb-Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/jenkinsci-dev/CAMo7PtJiFhOTAcMwELiuz3w9iza51DLJFF%3Df4tidnuQfzpZb-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB-ucX5_PbO3CmUu8PiJw11Cde5%3DM9%2BuEw3SxD_YgTmfcQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/CA%2Bb6JB-ucX5_PbO3CmUu8PiJw11Cde5%3DM9%2BuEw3SxD_YgTmfcQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAH-3Bid-_j5z8DnLs3QZ%3DF0tn5RGTEGmWO_Yt%3DvE22w9HkjvJA%40mail.gmail.com.

Reply via email to